mirror of
https://github.com/mjl-/mox.git
synced 2024-12-25 16:03:48 +03:00
use shorter smtp.NewAddress() instead of smtp.Address{...}
This commit is contained in:
parent
1179d9d80a
commit
ebb8ad06b5
9 changed files with 10 additions and 10 deletions
|
@ -779,7 +779,7 @@ func sendReportDomain(ctx context.Context, log mlog.Log, resolver dns.Resolver,
|
||||||
// DKIM keys, so we can DKIM-sign our reports. SPF should pass anyway.
|
// DKIM keys, so we can DKIM-sign our reports. SPF should pass anyway.
|
||||||
// A single report can contain deliveries from a single policy domain
|
// A single report can contain deliveries from a single policy domain
|
||||||
// to multiple of our configured domains.
|
// to multiple of our configured domains.
|
||||||
from := smtp.Address{Localpart: "postmaster", Domain: mox.Conf.Static.HostnameDomain}
|
from := smtp.NewAddress("postmaster", mox.Conf.Static.HostnameDomain)
|
||||||
|
|
||||||
// Subject follows the form in RFC. ../rfc/7489:1871
|
// Subject follows the form in RFC. ../rfc/7489:1871
|
||||||
subject := fmt.Sprintf("Report Domain: %s Submitter: %s Report-ID: <%s>", dom.ASCII, mox.Conf.Static.HostnameDomain.ASCII, report.ReportMetadata.ReportID)
|
subject := fmt.Sprintf("Report Domain: %s Submitter: %s Report-ID: <%s>", dom.ASCII, mox.Conf.Static.HostnameDomain.ASCII, report.ReportMetadata.ReportID)
|
||||||
|
|
|
@ -107,7 +107,7 @@ func ExampleComposer() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Add an address header.
|
// Add an address header.
|
||||||
xc.HeaderAddrs("From", []message.NameAddress{{DisplayName: "Charlie", Address: smtp.Address{Localpart: "root", Domain: dns.Domain{ASCII: "localhost"}}}})
|
xc.HeaderAddrs("From", []message.NameAddress{{DisplayName: "Charlie", Address: smtp.NewAddress("root", dns.Domain{ASCII: "localhost"})}})
|
||||||
|
|
||||||
// Add subject header, with encoding
|
// Add subject header, with encoding
|
||||||
xc.Subject("hi ☺")
|
xc.Subject("hi ☺")
|
||||||
|
|
|
@ -51,6 +51,6 @@ func From(elog *slog.Logger, strict bool, r io.ReaderAt, p *Part) (raddr smtp.Ad
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return raddr, nil, nil, fmt.Errorf("parsing localpart in from address: %v", err)
|
return raddr, nil, nil, fmt.Errorf("parsing localpart in from address: %v", err)
|
||||||
}
|
}
|
||||||
addr := smtp.Address{Localpart: lp, Domain: d}
|
addr := smtp.NewAddress(lp, d)
|
||||||
return addr, p.Envelope, textproto.MIMEHeader(header), nil
|
return addr, p.Envelope, textproto.MIMEHeader(header), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,14 +505,14 @@ func DomainAdd(ctx context.Context, domain dns.Domain, accountName string, local
|
||||||
} else if accountName == "" {
|
} else if accountName == "" {
|
||||||
return fmt.Errorf("%w: account name is empty", ErrRequest)
|
return fmt.Errorf("%w: account name is empty", ErrRequest)
|
||||||
} else if !ok {
|
} else if !ok {
|
||||||
nc.Accounts[accountName] = MakeAccountConfig(smtp.Address{Localpart: localpart, Domain: domain})
|
nc.Accounts[accountName] = MakeAccountConfig(smtp.NewAddress(localpart, domain))
|
||||||
} else if accountName != Conf.Static.Postmaster.Account {
|
} else if accountName != Conf.Static.Postmaster.Account {
|
||||||
nacc := nc.Accounts[accountName]
|
nacc := nc.Accounts[accountName]
|
||||||
nd := map[string]config.Destination{}
|
nd := map[string]config.Destination{}
|
||||||
for k, v := range nacc.Destinations {
|
for k, v := range nacc.Destinations {
|
||||||
nd[k] = v
|
nd[k] = v
|
||||||
}
|
}
|
||||||
pmaddr := smtp.Address{Localpart: "postmaster", Domain: domain}
|
pmaddr := smtp.NewAddress("postmaster", domain)
|
||||||
nd[pmaddr.String()] = config.Destination{}
|
nd[pmaddr.String()] = config.Destination{}
|
||||||
nacc.Destinations = nd
|
nacc.Destinations = nd
|
||||||
nc.Accounts[accountName] = nacc
|
nc.Accounts[accountName] = nacc
|
||||||
|
|
|
@ -673,7 +673,7 @@ many authentication failures).
|
||||||
// Messages to postmaster will get to the account too.
|
// Messages to postmaster will get to the account too.
|
||||||
var contactEmail string
|
var contactEmail string
|
||||||
if addr.Localpart.IsInternational() {
|
if addr.Localpart.IsInternational() {
|
||||||
contactEmail = smtp.Address{Localpart: "postmaster", Domain: addr.Domain}.Pack(false)
|
contactEmail = smtp.NewAddress("postmaster", addr.Domain).Pack(false)
|
||||||
} else {
|
} else {
|
||||||
contactEmail = addr.Pack(false)
|
contactEmail = addr.Pack(false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ func Verify(elog *slog.Logger, r io.ReaderAt, key []byte, period time.Duration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%w: from address with bad localpart: %v", ErrFrom, err)
|
return fmt.Errorf("%w: from address with bad localpart: %v", ErrFrom, err)
|
||||||
}
|
}
|
||||||
addr := smtp.Address{Localpart: lp, Domain: d}.Pack(true)
|
addr := smtp.NewAddress(lp, d).Pack(true)
|
||||||
|
|
||||||
buf, err := base64.RawURLEncoding.DecodeString(token)
|
buf, err := base64.RawURLEncoding.DecodeString(token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -508,7 +508,7 @@ func sendReportDomain(ctx context.Context, log mlog.Log, resolver dns.Resolver,
|
||||||
// typical setup the host is a subdomain of a configured domain with
|
// typical setup the host is a subdomain of a configured domain with
|
||||||
// DKIM keys, so we can DKIM-sign our reports. SPF should pass anyway.
|
// DKIM keys, so we can DKIM-sign our reports. SPF should pass anyway.
|
||||||
// todo future: when sending, use an SMTP MAIL FROM that we can relate back to recipient reporting address so we can stop trying to send reports in case of repeated delivery failure DSNs.
|
// todo future: when sending, use an SMTP MAIL FROM that we can relate back to recipient reporting address so we can stop trying to send reports in case of repeated delivery failure DSNs.
|
||||||
from := smtp.Address{Localpart: "postmaster", Domain: fromDom}
|
from := smtp.NewAddress("postmaster", fromDom)
|
||||||
|
|
||||||
// Subject follows the form from RFC. ../rfc/8460:959
|
// Subject follows the form from RFC. ../rfc/8460:959
|
||||||
subject := fmt.Sprintf("Report Domain: %s Submitter: %s Report-ID: <%s>", polDom.ASCII, fromDom, report.ReportID)
|
subject := fmt.Sprintf("Report Domain: %s Submitter: %s Report-ID: <%s>", polDom.ASCII, fromDom, report.ReportID)
|
||||||
|
|
|
@ -1229,7 +1229,7 @@ func (s server) MessageGet(ctx context.Context, req webapi.MessageGetRequest) (r
|
||||||
|
|
||||||
var msgFrom string
|
var msgFrom string
|
||||||
if d, err := dns.ParseDomain(m.MsgFromDomain); err == nil {
|
if d, err := dns.ParseDomain(m.MsgFromDomain); err == nil {
|
||||||
msgFrom = smtp.Address{Localpart: m.MsgFromLocalpart, Domain: d}.Pack(true)
|
msgFrom = smtp.NewAddress(m.MsgFromLocalpart, d).Pack(true)
|
||||||
}
|
}
|
||||||
meta := webapi.MessageMeta{
|
meta := webapi.MessageMeta{
|
||||||
Size: m.Size,
|
Size: m.Size,
|
||||||
|
|
|
@ -187,7 +187,7 @@ func fromAddrViewMode(tx *bstore.Tx, from MessageAddress) (store.ViewMode, error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return store.ModeDefault, nil
|
return store.ModeDefault, nil
|
||||||
}
|
}
|
||||||
fromAddr := smtp.Address{Localpart: lp, Domain: from.Domain}.Pack(true)
|
fromAddr := smtp.NewAddress(lp, from.Domain).Pack(true)
|
||||||
fas := store.FromAddressSettings{FromAddress: fromAddr}
|
fas := store.FromAddressSettings{FromAddress: fromAddr}
|
||||||
err = tx.Get(&fas)
|
err = tx.Get(&fas)
|
||||||
if err == bstore.ErrAbsent {
|
if err == bstore.ErrAbsent {
|
||||||
|
|
Loading…
Reference in a new issue