mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-14 16:21:18 -05:00
* adds pkg/jmap/jmap_integration_test.go
* uses ghcr.io/stalwartlabs/stalwart:v0.13.2-alpine
* can be disabled by setting one of the following environment
variables, in the same fashion as ca0493b28
- CI=woodpecker
- CI_SYSTEM_NAME=woodpecker
- USE_TESTCONTAINERS=false
* dependencies:
- bump github.com/go-test/deep from 1.1.0 to 1.1.1
- add github.com/cention-sany/utf7
- add github.com/dustinkirkland/golang-petname
- add github.com/emersion/go-imap/v2
- add github.com/emersion/go-message
- add github.com/emersion/go-sasl
- add github.com/go-crypt/crypt
- add github.com/go-crypt/x
- add github.com/gogs/chardet
- add github.com/inbucket/html2text
- add github.com/jhilleryerd/enmime/v2
- add github.com/ssor/bom
- add gopkg.in/loremipsum.v1
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package mail
|
|
|
|
import (
|
|
"mime"
|
|
"net/mail"
|
|
"strings"
|
|
|
|
"github.com/emersion/go-message"
|
|
)
|
|
|
|
// Address represents a single mail address.
|
|
// The type alias ensures that a net/mail.Address can be used wherever an
|
|
// Address is expected
|
|
type Address = mail.Address
|
|
|
|
func formatAddressList(l []*Address) string {
|
|
formatted := make([]string, len(l))
|
|
for i, a := range l {
|
|
formatted[i] = a.String()
|
|
}
|
|
return strings.Join(formatted, ", ")
|
|
}
|
|
|
|
// ParseAddress parses a single RFC 5322 address, e.g. "Barry Gibbs <bg@example.com>"
|
|
// Use this function only if you parse from a string, if you have a Header use
|
|
// Header.AddressList instead
|
|
func ParseAddress(address string) (*Address, error) {
|
|
parser := mail.AddressParser{
|
|
&mime.WordDecoder{message.CharsetReader},
|
|
}
|
|
return parser.Parse(address)
|
|
}
|
|
|
|
// ParseAddressList parses the given string as a list of addresses.
|
|
// Use this function only if you parse from a string, if you have a Header use
|
|
// Header.AddressList instead
|
|
func ParseAddressList(list string) ([]*Address, error) {
|
|
parser := mail.AddressParser{
|
|
&mime.WordDecoder{message.CharsetReader},
|
|
}
|
|
return parser.ParseList(list)
|
|
}
|