Uploaded ASP.NET web application does not send email -
i developing web application, planned send confirmation emails new members. new email service development aspet. app runs without error or exception, , apparently sends emails try , catch blocks return ano exception. however, no 1 receives mail. here code:
using system; using system.net; using system.web; using system.net.mail; using system.collections.generic; using system.componentmodel.composition; using system.text.regularexpressions; public void sendemailaddressverificationemail(string username, string to) { mefmanager.compose(this); string encryptedname = username.encrypt("verify"); string msg = "please click on link below or paste browser verify email account.<br><br>" + "<a href=\"" + _configuration.rooturl + "account/verifyemail.aspx?a=" + encryptedname + "\">" + _configuration.rooturl + "account/verifyemail.aspx?a=" + encryptedname + "</a>"; sendemail(to, "", "", "account created! email verification required.", msg); } public void sendemail(string to, string cc, string bcc, string subject, string message) { mailmessage mm = new mailmessage(from_email_address,to); if(!string.isnullorempty(cc)) mm.cc.add(cc); if (!string.isnullorempty(bcc)) mm.bcc.add(bcc); mm.subject = subject; mm.body = message; mm.isbodyhtml = true; send(mm); } private void send(mailmessage message) { try { //during developement not sending mails #if !debug smtpclient smtp = new smtpclient(); smtp.send(message); console.write("e-mail sent!"); #endif } catch(exception ex) { console.write("could not send e-mail - error: " + ex.message); } }
also web.config , web.release.config files follows:
web.config:
<system.net> <mailsettings> <smtp> <network host="localhost" port="25" defaultcredentials="true"/> </smtp> </mailsettings> </system.net>
web.release.config:
<smtp from="postmaster@itok.com"> <network host="mail.itok.com" defaultcredentials="true" enablessl="false" port="25" username="postmaster@itok.com" password="*********" xdt:transform="replace" /> </smtp>
can me find reason? have idea or suggestion answer? sources of such problem?
i can't answer question, here few tips long put in comment.
in development environment, enable sending mails using delivery method specifiedpickupdirectory
, rather using conditional compilation disable sending mails (if !debug...
).
this enable test code in development environment - check email files being created in specified directory (which must exist , writable web application).
<smtp deliverymethod="specifiedpickupdirectory" from="postmaster@itok.com"> <network host="localhost"/> <specifiedpickupdirectory pickupdirectorylocation="c:\temp\mails\"/> </smtp>
if works in development environment, can assume code ok, , problem deployed configuration.
your use of console.write
log errors in web application looks suspicious: expecting see these errors?
Comments
Post a Comment