c# - SMTP send email works offline but not online -
i have simple contact page on private homepage.
offline works perfectly, online nothing happens.
any idea?
protected void page_load(object sender, eventargs e) { if (!ispostback) { btnsend.attributes.add("onmouseover", "changeimg('" + btnsend.clientid + "', 'images/senden_hover.jpg');"); btnsend.attributes.add("onmouseout", "changeimg('" + btnsend.clientid + "', 'images/senden.jpg')"); } } protected void btnsend_click(object sender, imageclickeventargs e) { if (!string.isnullorempty(txtnachricht.text)) { sendemailusercontact(txtabsender.text, txtnachricht.text); response.redirect("~/contact_suc.aspx", false); } } public static void sendemailusercontact(string betreff, string nachricht) { sendemail(betreff, nachricht, "von@exampl.com", "an@example.com"); } private static void sendemail(string betreff, string nachricht, string von, string an) { ///zambuu string strsmtpserver = "smtp.example.com"; string struser = "kontakt@example.com"; string strpasswort = "xxx"; mailmessage mail = new mailmessage(); mailaddress = new mailaddress(von); mail.to.add(an); mail.from = from; mail.subject = betreff; mail.body = nachricht; string host = strsmtpserver; int port = 25; smtpclient client = new smtpclient(host, port); networkcredential nc = new networkcredential(struser, strpasswort); client.credentials = nc; client.send(mail); }
i believe smtp have approve sender. machine hosts online contact page, different machine 1 developing on. have give access on mailserver on machine hosts page.
Comments
Post a Comment