smtp: server doesn't support AUTH

1.4k Views Asked by At

Hi i am trying to develop a simple SMTP application using golang, but my smtp server doesnt support Auth it doesnt require a user name or password. But in Go lang it uses plain auth authentication which passes a password but i am getting the above error smtp: server doesn't support AUTH.

Please find the below piece of code which i am using to implement the SMTP part,

package main

import (
    "log"

    "net/smtp"
)

func main() {

    // Configuration

    from := "[email protected]"

    password := "12345samplemail"

    to := []string{"[email protected]"}

    smtpHost := "smtp.gmail.com"

    smtpPort := "587"

    message := []byte("Hello! I'm trying out smtp to send emails to recipients.")

    // Create authentication

    auth := smtp.PlainAuth("", from, password, smtpHost)

    // Send actual message

    err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, to, message)

    if err != nil {

        log.Fatal(err)

    }

}
0

There are 0 best solutions below