-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Username and Password not accepted #133
Comments
Seconded. I have seeing the same issue too. |
see #108 |
Hi, I have this problem too!! does anyone solve this issue? I didn't find anything in #108 as @pedromorgan mentioned in the above comment. |
@Alireza-cman did you finally find a solution? I am also experiencing this issue. |
I had a similar problem connecting to office365. Office 365 needs LoginAuth. I achieved this by creating a custom method to implement this. Create a file and paste the below code import (
"net/smtp"
"errors"
)
type loginAuth struct {
username, password string
}
func LoginAuth(username, password string) smtp.Auth {
return &loginAuth{username, password}
}
func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
return "LOGIN", []byte{}, nil
}
func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
if more {
switch string(fromServer) {
case "Username:":
return []byte(a.username), nil
case "Password:":
return []byte(a.password), nil
default:
return nil, errors.New("Unkown fromServer")
}
}
return nil, nil
} Generate LoginAuth below ...
auth := LoginAuth(username, password)
... Then add the generated auth to gomail ...
d := gomail.NewDialer(server, port, username, pass)
d.Auth = auth // add LoginAuth generated above
// Send the email
if err := d.DialAndSend(m); err != nil {
log.Printf(" cant send email got error %s ", err.Error())
return false
}
... |
@mudphilo thanks, it worked |
`panic: 535 5.7.8 Username and Password not accepted. Learn more at
5.7.8 https://support.google.com/mail/?p=BadCredentials 195sm9531505pfc.50 - gsmtp
goroutine 1 [running]:
main.SendEmail()`
The text was updated successfully, but these errors were encountered: