Skip to content

Notifications emails are not sent due to invalid From #3615

Closed
@strk

Description

@strk

Noticing I was not receiving email notifications I checked the logs and found:

gomail: could not send email 1: gomail: invalid address "\"bjornharrtell\" <>": mail: invalid string

As the user bjornharrtell has a valid email registered (checked via web UI and on the database), I went looking at code and found this in modules/log/smtp.go:

    mailmsg := []byte("To: " + strings.Join(s.RecipientAddresses, ";") + "\r\nFrom: " + s.Username + "<" + s.Username +
        ">\r\nSubject: " + s.Subject + "\r\n" + content_type + "\r\n\r\n" + fmt.Sprintf(".%s", time.Now().Format("2006-01-02 15:04:05")) + msg)

    return smtp.SendMail(                                                       
        s.Host,                                                                 
        auth,                                                                   
        s.Username,                                                             
        s.RecipientAddresses,                                                   
        mailmsg,                                                                
    )             

Note how s.Username is used for the From field both in the mail header and in the smtp.SendMail 3rd parameter.

I suspect smtp.SendMail just refuses such From address (lacking an @ character) and fails to send anything.

I believe things did work as of 0.9.68, while are failing as of 0.9.99

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions