go-gomail / gomail

The best way to send emails in Go.
MIT License
4.29k stars 569 forks source link

Email doesnt send if there is one of receipts address invalid #192

Open shyandsy opened 5 months ago

shyandsy commented 5 months ago

error: Recipient address rejected

if there is a list of receipts, and one of them is invalid, gomail will abort whole sending process, and it not make sense

func (c *smtpSender) Send(from string, to []string, msg io.WriterTo) error {
    if err := c.Mail(from); err != nil {
        if err == io.EOF {
            // This is probably due to a timeout, so reconnect and try again.
            sc, derr := c.d.Dial()
            if derr == nil {
                if s, ok := sc.(*smtpSender); ok {
                    *c = *s
                    return c.Send(from, to, msg)
                }
            }
        }
        return err
    }

        // !!!! it doesnt send any email if there is an invalid email address 
    for _, addr := range to {
        if err := c.Rcpt(addr); err != nil {
            return err
        }
    }

    w, err := c.Data()
    if err != nil {
        return err
    }

    if _, err = msg.WriteTo(w); err != nil {
        w.Close()
        return err
    }

    return w.Close()
}
wneessen commented 4 months ago

This is a know bug but unfortunately won't be fixed since the maintainer has sadly passed away.

You might want to consider checking wneessen/go-mail which has addressed this issue and has dedicated error detection for failed bulk mails.

shyandsy commented 4 months ago

it can be archieved by remove invlid email address instead of return error

i can make a pr if u agree with my solution

Yang Shi 201-15 bridgeland dr south R3Y 0E7

Winni Neessen @.***>于2024年2月14日 周三20:36写道:

This is a know bug but unfortunately won't be fixed since the maintainer has sadly passed away https://github.com/go-gomail/gomail/issues/182.

You might want to consider checking wneessen/go-mail https://github.com/wneessen/go-mail which has addressed this issue and has dedicated error detection for failed bulk mails.

— Reply to this email directly, view it on GitHub https://github.com/go-gomail/gomail/issues/192#issuecomment-1943687213, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIG7INDA7C6474JHY33BC3YTSVVHAVCNFSM6AAAAABCKAOGZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBTGY4DOMRRGM . You are receiving this because you authored the thread.Message ID: @.***>

wneessen commented 4 months ago

I am not the maintainer of this repository. As mentioned, the maintainer passed away and and PR won't be accepted anymore.

shyandsy commented 4 months ago

ok……

thanks for your.reply

Yang Shi 201-15 bridgeland dr south R3Y 0E7

Winni Neessen @.***>于2024年2月15日 周四02:28写道:

I am not the maintainer of this repository. As mentioned, the maintainer passed away and and PR won't be accepted anymore.

— Reply to this email directly, view it on GitHub https://github.com/go-gomail/gomail/issues/192#issuecomment-1944375510, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIG7IIJJMVBSE67JXXWGWTYTT64JAVCNFSM6AAAAABCKAOGZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBUGM3TKNJRGA . You are receiving this because you authored the thread.Message ID: @.***>