-
C# emailing SSL with bluehost
I know that it says you can do it but what is the secret? I am trying to use Bluehost's SSL email feature to send emails utilizing a C# app I wrote.
Can someone please help? I did try and ask Bluehost but they "don't provide support for custom coding."
Here is the code:
Replace all "yourname" with your actual site to test.
using System.Net;
using System.Net.Mail;
private bool EmailTest()
{
try
{
// Create a mailing address that includes a UTF8 character in the display name.
MailAddress oFromAddress = new MailAddress("yourname@yourdomain.com", "Your Name");
// Set destinations for the e-mail message.
MailAddress oToAddress = new MailAddress("foo@gmail.com");
// Specify the message content.
MailMessage oMailMessage = new MailMessage(oFromAddress, oToAddress);
oMailMessage.Body = "This is a test e-mail message sent by an application. ";
oMailMessage.BodyEncoding = Encoding.UTF8;
oMailMessage.Subject = "test SSL message from bluehose";
oMailMessage.SubjectEncoding = Encoding.UTF8;
oMailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
// sending using SSL
string smtpServer = "box100.bluehost.com";
int smtpPort = 465;
SmtpClient oSMTPClient = new SmtpClient(smtpServer, smtpPort);
oSMTPClient.Host = "mail.yourhost.com";
oSMTPClient.UseDefaultCredentials = false;
NetworkCredential smtpCcredentials = new System.Net.NetworkCredential("yourname@yourdomain. com", "yourpassword");
oSMTPClient.Credentials = smtpCcredentials;
oSMTPClient.EnableSsl = true;
oSMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network;
oSMTPClient.Timeout = 5000;
oSMTPClient.Send(oMailMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
return true;
}
I am getting typical, unhelpful message, "The operation has timed out." which indicates no connection. No changing the SMTP timeout to a higher value does not work. I have tested this with gmail's SSL and it works.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules