PDA

View Full Version : Email Not Sending on SSL Page


bermanbp
06-10-2009, 11:12 PM
Hi Everyone,

I have a strange problem where email messages are not sending from a page with an SSL certificate installed. The same codebase, on the same server (my staging site) sends the email fine. I have it set up through IIS SMTP relay on localhost. The PTR records are set up as well.

The simple code is below (ASP.NET 2.0):
Mail.Send(new MailAddress(tbEmail.Text), new MailAddress("receipt@myserver.com"), "THANK YOU for Your Donation: RECEIPT " + identity, Server.MapPath("/MailTemplates/donationReceipt.txt"), parameters, false);

Has anyone ever experienced an issue like this? It doesn't seems to be throwing any errors.

Thanks,
Brett

HostingASPNet
07-03-2009, 08:33 AM
Hello,

You could try to debug it, but the code seems OK.

Regards

scottk
07-16-2009, 10:24 PM
Are you receiving an exception or is the email just not showing up? And what class exposes Mail.Send() are you using a third party library?

Try something like this:

public static SmtpClient GetSmtpClient()
{
SmtpClient smtp = new SmtpClient(WebConfigurationVariables.SMTPServer);
if (WebConfigurationVariables.SMTPUseAuth)
{
smtp.Credentials = new NetworkCredential(WebConfigurationVariables.SMTPUsername, WebConfigurationVariables.SMTPPassword);
}
return smtp;
}
try
{
SmtpClient smtp = SMTPHelper.GetSmtpClient();
using (MailMessage msg = new MailMessage())
{
msg.From = new MailAddress("feedback@website", "Online Feedback");
msg.Sender = new MailAddress("feedback@website", "Online Feedback");
msg.To.Add(new MailAddress(WebConfigurationVariables.FeedbackEmail));
msg.Subject = "Feedback from website";
msg.Body = "message body";
msg.IsBodyHtml = false;
msg.ReplyTo = new MailAddress("noreply@website", "No Reply");
smtp.Send(msg);
}
}
catch (Exception ex)
{
Log.Exception(ex, Request);
}