email - Send gmail from web application hosted on Azure -
newbie azure, got application published cloud needed database backends (sql server).
everything within application working expected except email functionality. sending out email alerts via gmail account, not appear sent out. application not crash , trying configure remote debugging has proven difficult.
this snippet using send out emails:
//parse html document show in outgoing email streamreader reader = new streamreader(httpcontext.current.server.mappath(configurationmanager.appsettings["template"])); string body = reader.readtoend(); //populate placeholders message variables body = body.replace("<%holder%>", value); ...omitted brevity seek { var smtp = new smtpclient { host = "smtp.gmail.com", port = 587, enablessl = true, deliverymethod = smtpdeliverymethod.network, usedefaultcredentials = false, credentials = new networkcredential(fromaddress.address, frompassword) }; using (var message = new mailmessage(fromaddress, toaddress) { isbodyhtml = true, subject = subject, body = body, }) { smtp.send(message); } }
application didn't crash, no error message go off of. thought maybe wasn't able grab file in lines:
streamreader(httpcontext.current.server.mappath(configurationmanager.appsettings["template"])); string body = reader.readtoend();
so tried sending hardcoded string test:
string body = "test";
still no email received , no error message go off of. i'm new azure web hosting, there configuration missing here? azure allow sending email through 3rd party email clients? fyi - above code works against localhost.
sending e-mail public cloud not trivial people believe. there lot of things figure out in order not blacklisted. when intend utilize public mail service service.
my first guess azure info center ip addresses (or 1 hosted on) might blacklisted mail service servers (including microsoft's own office 365).
i have mention recommended way sending e-mail application hosted in azure using sendgrid. have free tier. more info from microsoft on subject, can found here.
the way troubleshoot exact cause of problem contact gmail back upwards , inquire them if block in way network clients connecting azure cloud. or create vm in same info center web application lives, install free / trial mail service client, configure google mail service , seek send e-mails. result same application.
email azure smtp gmail
No comments:
Post a Comment