c# - Email sent through localhost but not sent when I try to send from my Server -
email sent through localhost not sent when try send server.
what do.
note : use port
25 , host
: mail.mydomain.com.
failure sending mail.
could me please?
i have used code:
public static string sendmail(string host , string , string pass , int port , string pto, string subject, string body, string attach) { string host = host; string receiveremailaddres = pto; string senderemailaddresss = from; string senderemailpassword = pass; smtpclient mymail = new smtpclient(); mailmessage mymsg = new mailmessage(); mymail.host = host; mymail.port = port; mymsg.to.add(new mailaddress(receiveremailaddres)); mymsg.subject = subject; if (attach != string.empty) { attachment data = new attachment(attach); mymsg.attachments.add(data); } mymsg.isbodyhtml = true; mymsg.from = new mailaddress(senderemailaddresss); mymsg.body = body; mymail.usedefaultcredentials = false; networkcredential mycredentials = new networkcredential(senderemailaddresss, senderemailpassword); mymail.credentials = mycredentials; try { mymail.send(mymsg); return "ok"; } catch(exception ex) { return ex.message; } }
check firewall configurations if blocking outgoing connection port 25 (used send e-mails). due lack of 50 rep points not able first comment , ask if tried or firewall configuration looks like. if want receive emails should check if firewall blocking incoming connection port 110 (pop3) or 143 (imap4, no tls) / 993 (imap4, tls).
Comments
Post a Comment