Skip to content

Commit ab24fe7

Browse files
arp242emersion
authored andcommitted
Remove superfluous validateLine() calls in sendMail()
Client.SendMail() already calls validateLine() via Client.Mail() and Client.Rcpt(), so there is no need to have these checks in sendMail(). Having these checks don't hurt as such, but looking at just the sendMail() function it's not obvious whether these checks are needed if you want to implement your own SendMail()-type function. With this change, you can copy/paste sendMail(), add the smtp. package selector, and modify as needed. Also removes a superfluous nil check as a bonus.
1 parent 6944e33 commit ab24fe7

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

client.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func (c *Client) Rcpt(to string, opts *RcptOptions) error {
499499
sb.Grow(2048)
500500
fmt.Fprintf(&sb, "RCPT TO:<%s>", to)
501501
if _, ok := c.ext["DSN"]; ok && opts != nil {
502-
if opts.Notify != nil && len(opts.Notify) != 0 {
502+
if len(opts.Notify) != 0 {
503503
sb.WriteString(" NOTIFY=")
504504
if err := checkNotifySet(opts.Notify); err != nil {
505505
return errors.New("smtp: Malformed NOTIFY parameter value")
@@ -744,15 +744,6 @@ func (c *Client) SendMail(from string, to []string, r io.Reader) error {
744744
var testHookStartTLS func(*tls.Config) // nil, except for tests
745745

746746
func sendMail(addr string, implicitTLS bool, a sasl.Client, from string, to []string, r io.Reader) error {
747-
if err := validateLine(from); err != nil {
748-
return err
749-
}
750-
for _, recp := range to {
751-
if err := validateLine(recp); err != nil {
752-
return err
753-
}
754-
}
755-
756747
var (
757748
c *Client
758749
err error

0 commit comments

Comments
 (0)