cant send email from ASP.NET pages Hi, I've looked thru many of the threads regarding this and my code is identical but I am not receiving any emails when I send using the code. Can someone help? my domain is domain.com I have set Full trust in web.config I see some threads have error but I get not errors when I try and send it simply goes thru but where are they recorded anyway just in case? I updated the port but still no luck. This is quite urgent. $10 donation to the first person gets it right why does this not work. DISCLAIMER: I'll decide what post and person made it work Code: MailMessage mm = new MailMessage(@"[email protected]", @"[email protected]"); mm.Body = string.Format("Enquiry from website: From {0} name {1} regarding {2} message {3}", email, name, subject, message); mm.Subject = "Enquiry from Website"; mm.IsBodyHtml = false; using (SmtpClient smtpClient = new SmtpClient("mail.domain.com")) { //smtpClient.UseDefaultCredentials = false; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential("[email protected]", "password"); smtpClient.EnableSsl = false; smtpClient.Port = 587; smtpClient.Send(mm); } }
I updated the port but still no luck. This is quite urgent. $10 donation to the first person gets it right why does this not work. DISCLAIMER: I'll decide what post and person made it work Code: MailMessage mm = new MailMessage(@"[email protected]", @"[email protected]"); mm.Body = string.Format("Enquiry from website: From {0} name {1} regarding {2} message {3}", email, name, subject, message); mm.Subject = "Enquiry from Website"; mm.IsBodyHtml = false; using (SmtpClient smtpClient = new SmtpClient("mail.domain.com")) { //smtpClient.UseDefaultCredentials = false; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential("[email protected]", "password"); smtpClient.EnableSsl = false; smtpClient.Port = 587; smtpClient.Send(mm); } }
Did you take a look at our knowledge base article? No need to set the port it will default to 25. I'm assuming you updated your password with your actual site password, is that right?
yep, I have substituted with password and tried port 25 and 587 neither worked and the code is identical to the article. This has been working perfectly fine locally until the DNS propagation / moving of domain. Could it be the MX record?
Everything looks correct. You can try disabling greylisting by going to Settings -> Account Settings -> Disable greylisting. The MX record is also fine.
thank you. Yes it does look correct but it is not working and unless I can get this part working I will have to take my business somewhere else This is basic coding I have done many times and I currently have working in other apps. I am not expecting problems with this
hi, If you are having problem using you smtp server you can use Gmail smpt to send email. function gmailSmtp($from,$to,$subject,$body,$bcc = false){ require_once "Mail.php"; $body = stripslashes(stripslashes($body)); $host = "ssl://smtp.gmail.com"; $port = "465"; $username = "username"; $password = "password"; if($bcc){ $headers = array ( 'MIME-Version'=> '1.0', 'Content-type' => 'text/html; charset=iso-8859-1', 'From' => $from, 'RCPT TO' => $to, 'Subject' => $subject ); }else{ $headers = array ( 'MIME-Version'=> '1.0', 'Content-type' => 'text/html; charset=iso-8859-1', 'From' => $from, 'To' => $to, 'Subject' => $subject ); } //print_r($headers);die; $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { return $mail->getMessage(); } else { return 1; } } The above function is in php to use smpt mail service. Let me know if issues with this Thanks CoreIT Developers
If you don't get any error when executing the code, the problem is not the code :> Try use another from address. If there's any problem with the email server, it should send a bounce with the error message. I see that you are using the a user on the same domain, you might not get the bounce then. If you still have problem, create a support ticket, we might be able to check where the mail went.
@deepak thanks for your post. Unfortunately gmail was one of the first I tried when it didn't work immediately and it made not difference
sorry...my fault the event wasn't being raised correctly to fire the code <CRAP_EXCUSE>I am sure it was when I deployed it</CRAP_EXCUSE> sorry about that. Working fine now