Send an email from the program code

165 views
Skip to first unread message

notsu...@gmail.com

unread,
Oct 20, 2011, 1:24:35 PM10/20/11
to golan...@googlegroups.com
The task is send email via smtp. Server is smtp.yandex.ru. When I had tried to send email truoth a smtp.SendEmail function I got the error like this "503 5.5.4 Error: send AUTH first". What the reason? The second question is how to send an email without SSL/TLS connections?

chris #golang

unread,
Oct 20, 2011, 2:10:53 PM10/20/11
to golang-nuts
I could swear it means that you need an authentification to get access
to the server. In this group I found the following code:

func main() {
auth := smt.PlainAuth("", "u...@example.com", "password",
"mail.example.com")
err := smtp.SendMail("mail.example.com:25", auth,
"sen...@example.org", []string{"recipi...@example.net"}, []byte("This
is the email body."))
if err != nil {
log.Fatal(err)
}
}

I hope that helps you somehow (I've not done stuff like that yet),
chris.

Reason

unread,
Feb 16, 2012, 8:14:38 AM2/16/12
to golan...@googlegroups.com
Hi!

After some tests I've  found that the SendEmail function works only with gmail accounts (from gmail && to gmail), but if you want to send email from an other or to the other account (for example, some...@yandex.ru) it doesn't work.

Archos

unread,
Feb 16, 2012, 9:04:32 AM2/16/12
to golang-nuts
I've test it in my email server and it works.

If you get a message like this one:

==
2012/02/16 13:56:12 EOF
exit status 1
==

is because the port is wrong.

On Feb 16, 1:14 pm, Reason <notsurem...@gmail.com> wrote:
> Hi!
>
> After some tests I've  found that the SendEmail function works only with
> gmail accounts (from gmail && to gmail), but if you want to send email from
> an other or to the other account (for example, someN...@yandex.ru) it
> doesn't work.
Reply all
Reply to author
Forward
0 new messages