xhit / go-simple-mail

Golang package for send email. Support keep alive connection, TLS and SSL. Easy for bulk SMTP.
MIT License
650 stars 102 forks source link

Cant send mail #69

Closed wojtess closed 2 years ago

wojtess commented 2 years ago

Hello I cant send email, this is error code that i am getting: Mail Error on Auth: 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6

Code:


import (
    "fmt"

    mail "github.com/xhit/go-simple-mail/v2"
)

func main() {
    //Create the email message
    server := mail.NewSMTPClient()
    server.Host = "smtp.poczta.onet.pl"
    server.Port = 465
    server.Username = "username@op.pl"
    server.Password = "pass"

    server.Authentication = mail.AuthLogin
    server.Encryption = mail.EncryptionSSLTLS
    // server.TLSConfig = &tls.Config{InsecureSkipVerify: true}

    smtpClient, err := server.Connect()

    if err != nil {
        fmt.Println("error ")
        fmt.Println(err)
        return
    }

    fmt.Println("connected")

    email := mail.NewMSG()

    email.SetFrom("From aa <username@op.pl>").
        AddTo("").
        SetSubject("New Go Email")

    //Get from each mail
    email.GetFrom()
    email.SetBody(mail.TextPlain, "Hello Test")

    //Send with high priority
    email.SetPriority(mail.PriorityHigh)

    // always check error after send
    if email.Error != nil {
        fmt.Println(email.Error)
        return
    }

    //Pass the client to the email message to send it
    fmt.Println(email.Send(smtpClient))
}

Logs:

error 
Mail Error on Auth: 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6
xhit commented 2 years ago

Technically you are connecting to smtp server, but this returns auth fail, check your credentials and all smtp server parameters you send (auth type, smtp server port, etc...)

wojtess commented 2 years ago

Yes, the smtp option wasnt enabled in mail provider settings. My fault not the problem with lib, sorry.