Does Aspose.Network support SSL/TLS over SMTP server

Does Aspose.Network support SSL/TLS over SMTP server?

I saw the documentation it is saying It will suppot for IMAP and POP3

But we are using SMTP email server

My EMAIL server URL is something like this

smtp.mydomain.com

So I have concern, wheather Aspose.Network support secure email(SSL/TLS) on such server?

Please confirm.

Siraj

Hi Siraj,

You can use follow code to send email messages to smtp server.

[Test]
public void SslSend()
{
SmtpClient _smtpClient = new SmtpClient();
_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
_smtpClient.Host = “smtp.gmail.com”;
_smtpClient.Credentials = new NetworkCredentialEx("xxxx@gmail.com", “xxxx”);
_smtpClient.Port = 587;
_smtpClient.EnableSsl = true;
MailMessage _mailMessage = new MailMessage("xxxxx@gmail.com", “xxxx@hotmail.com”);
_mailMessage.Subject = "[UnitTest] SslSend "+DateTime.Now.ToLongTimeString();
_mailMessage.Body = "[UnitTest] SslSend ";
_mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
_mailMessage.Priority = MailPriority.High;

try
{
_smtpClient.Send(_mailMessage);
Console.WriteLine(“send done.”);

}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Assert.Fail();
}
}

Hi,

For more information you may also refer to the following pages in documentation.

Connecting to SMTP Server

Accessing Gmail on SSL

Hi,

The above code throwing following exception

When Iam trying to send email using SMPT

My Code

SmtpClient _smtpClient = new SmtpClient();

_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

_smtpClient.Host = "smtp.gmail.com";

_smtpClient.Username = "mohdsiraj20@gmail.com";

_smtpClient.Password = "***";

_smtpClient.Port = 465;

_smtpClient.EnableSsl = true;

MailMessage _mailMessage = new MailMessage("mohdsiraj20@gmail.com", "sirajm@info-sun.com");

_mailMessage.Subject = "[UnitTest] SslSend " + DateTime.Now.ToLongTimeString();

_mailMessage.Body = "[UnitTest] SslSend ";

_mailMessage.BodyEncoding = System.Text.Encoding.UTF8;

_mailMessage.Priority = MailPriority.High;

try

{

_smtpClient.Send(_mailMessage);

Console.WriteLine("send done.");

}

catch (Exception ex)

{

Console.WriteLine(ex.ToString());

//Assert.Fail();

}

"Failure sending mail."

Please suggest

Siraj