google-app-engine


Go, Appengine, SMTP, Gmail


For some reason I cannot figure out how to send emails using a gmail account, Appengine and Golang.
Here's what I've done:
I went to Google Cloud Platform > Appengine > Settings > Select Project and I added the gmail account on Email API authorized senders.
I' tried to make this work using the code from (https://golang.org/pkg/net/smtp/#pkg-examples) (func SendMail)
package main
import (
"log"
"net/smtp"
)
func main() {
// Set up authentication information.
auth := smtp.PlainAuth("", "user#gmail.com", "password", "smtp.gmail.com")
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step.
to := []string{"recipient#example.net"}
msg := []byte("To: recipient#example.net\r\n" +
"Subject: discount Gophers!\r\n" +
"\r\n" +
"This is the email body.\r\n")
err := smtp.SendMail(smtp.gmail.com:587", auth, "sender#example.org", to, msg)
if err != nil {
log.Fatal(err)
}
}
On the front-end (JavaScript) I get an unsuccessful response after trying to run this code.
I've been running this on the appengine staging server
I tried different smtp server, ports, users and it still not work (support.google.com/a/answer/176600?hl=en)
I found a few examples on github and some other blog and I tried them but it didn't make different.
github.com/golang/go/wiki/SendingMail
nathanleclaire.com/blog/2013/12/17/sending-email-from-gmail-using-golang/
On all the examples it everything looks straight forward but there's something that I'm definitely missing or misunderstanding.
There're some limitations with establishing raw tcp connections on GAE:
https://cloud.google.com/appengine/docs/go/sockets/#limitations_and_restrictions
I would recommend to use GAE mail api (which is slightly diffrent from standart smtp package) to send emails:
https://cloud.google.com/appengine/docs/go/mail/sending-receiving-with-mail-api

Related Links

Using non-persistence related methods and fields in persistence entity
Google app engine: problem with autoload reference keys!
Google App Engine fetch() and print
How to get current session with only the SID?
GQL Syntax condition
Trouble locating static audio file on Google App Engine
Final GAE vs AWS architectural decision
how to read ZipInputStream into CharArrayReader
Google app engine: personal experiences?
Uploading multiple files to blobstore (redux)
App Engine: Can I upload my local dev_appserver.datastore to the live datastore?
App Engine URL mapping
Sitemaps structure for large App Engine site
cheetah in appengine
Help to Upload zip file containing CSV file in GAE
Google App Engine: Using datastore with users who are not logged in

Categories

HOME
cheerio
codenvy
case
r-googlesheets
replace
google-cloud-functions
crystal-reports-2013
spin
pybossa
frequency-distribution
gource
enterprise-architect
eip
atlassian
entitymanager
intershop
dreamweaver
forgot-password
smartclient
xmonad
mongoid6
moses
corpus
mat
entity-relationship-model
firebase-analytics
8051
handler
carrierwave
constexpr
scatter3d
paragraph
angularjs-material
glib
r-grid
rselenium
sammy.js
sql-delete
browser-extension
reason
apns-php
signals-slots
claims
ssrs-2014
outputcache
xmldocument
getchar
lampp
builder
chai-as-promised
convex-optimization
monkey
usart
stax
microstation
neon
jodd
i386
redis-cluster
phpgrid
state-restoration
rewrite
google-books
extjs-grid
pax-exam
sapscript
aspectj-maven-plugin
fail2ban
rrule
beatsmusic
jbake
filesplitting
psr-4
paw
ignite-ui
grails-plugin-rabbitmq
dct
memset
terminate
vsx
gd-graph
gtm-oauth2
sphinxql
hidapi
flex++
merb
scmmanager
actiondispatch
traceability
video-codecs
server-administration
chart-director
patricia-trie
nokia-s40
entity-attribute-value
ikimagebrowserview
role
filemerge
mbeans
codebase
twitterizer
cloudfiles
mtu
ruby-1.8
openfaces
glui
unmanagedresources
ifilter
lemmatization
image-capture

Resources

Encrypt Message