c# - Post back list of addresses and send out emails FAIL ON SMTP -


post address post method. want send email address:

 [httppost, actionname("index")]     public actionresult indexpost(suppliersindexvm allsuppliers)     {         mailmessage mail = new mailmessage();         smtpclient smtpserver = new smtpclient("smtp.gmail.com");          mail.from = new mailaddress("martin.lagan@umac-solutions.co.uk");         mail.to.add("martin.lagan@umac-solutions.co.uk");         mail.subject = "order";         mail.body = "i order following...";          smtpserver.send(mail);          return redirecttoaction("index");     } 

error coming last line: smptpserver.sed(mail)...

the smtp server requires secure connection or client not authenticated. server response was: 5.7.0 must issue starttls command first. b20sm10938791wiw.4 - gsmtp

any ideas guys.....also how can add tables etc email sending...cheers

i believe error due gmail requiring authentication before can allow send email through its' smtp server. can try add below code rid of issue.

smtpserver.enablessl = true; smtpserver.deliverymethod = smtpdeliverymethod.network; smtpserver.usedefaultcredentials = false; smtpserver.credentials = new system.net.networkcredential("emailaddress","password"); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -