0

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 := "samplemail@gmail.com"

    password := "12345samplemail"

    to := []string{"recipient@email.com"}

    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)

    }

}
Emile Pels
  • 3,837
  • 1
  • 15
  • 23
  • It is unclear for me what your problem is. If your SMTP server does not support auth, then you cannot use auth in your code - period. If you insist of using auth you need a SMTP server which supports it. – Steffen Ullrich Oct 20 '22 at 07:53
  • Hi Ullrich I completely get your point, I am very new to Go lang. Will you be able to help with any other approach in go to build smtp application without auth. – Buvnesh Venkatesan Oct 20 '22 at 09:38
  • Gmail no longer supports basic authentication: https://support.google.com/accounts/answer/6010255 – Kaspar Etter Oct 30 '22 at 19:17
  • Note that `nil` can be passed as the 'Auth' parameter, provided of course that the server being used doesn't require some form of authentication. – Greg A. Woods Nov 06 '22 at 23:31

0 Answers0