We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TLS Settings - Email Component - Not Working

Hello Aspose,


We are working on Aspose Email Component. As per our requirement, we have TLS enabled on SMTP server and in smtp client we are setting Aspose.Email.SecurityOptions.SSLExplicit = true like below this.

using (Aspose.Email.Mail.SmtpClient smtpObj = new Aspose.Email.Mail.SmtpClient(“", **, "”, “****”, Aspose.Email.SecurityOptions.SSLExplicit))
{
//Send the message
smtpObj.Send(msgObj);

Console.WriteLine(“E-mail has been sent successfully in TLS Support …”);
Console.ReadLine();
}

But it throwing, an exception like failure in sending email. at Aspose.Email.Mail.SmtpClient.BulkSend(IEnumerator messages)
at Aspose.Email.Mail.SmtpClient.Send(MailMessage message).

Could you please provide your support on this.

Kindly let me know if I need to modify any other settings regarding TLS on SMTP server.

Hi Ashpak,


Thank you for posting your inquiry.

Setting the SecurityOptions to SSLExplicit is the right way to do so. There are no other settings regarding the TLS that need to be set in the API. We don’t have idea about the SMTP server settings that you are using at our end. You may ask your network administrator for these settings and then test the settings correction by configuring the account in MS Outlook. Once the account is configured correctly and tested via MS Outlook, please test the issue again with the API and share your feedback with us.


Hello Muhammad Waqas,
Thank you for quick reply.

If i make TLS settings off on SMTP server and same [SSLExplicit = false ] at smtp client also, i am very well able to send email with that SMTP settings and Outlook settings.

As soon as, I clicked ON for TLS settings at smtp server, it starts mail sending failure.

Could you please review below detailed exception, hopefully that would give better idea.

Aspose.Email.Mail.SmtpException was caught
HResult=-2146233088
Message=Failure sending mail.
Source=Aspose.Email
StackTrace:
at Aspose.Email.Mail.SmtpClient.BulkSend(IEnumerator messages)
at Aspose.Email.Mail.SmtpClient.Send(MailMessage message)
at TLS_Support.Program.Main(String[] args) in c:\Users\Administrator\Documents\Visual Studio 2013\Projects\TLS_Support\Program.cs:line 74
InnerException: System.Security.Authentication.AuthenticationException
HResult=-2146233087
Message=The remote certificate is invalid according to the validation procedure.
Source=Aspose.Email
StackTrace:
at . (String , Int32 )
at . (Int32 )
at . ()
at Aspose.Email.Mail.SmtpClient.BulkSend(IEnumerator messages)
InnerException:

Hi Ashpak,


Please try ignoring or bypass the expired or invalid certificate by adding the following code to your application. This should solve the problem as you have stated. However, if the issue still remains, please share your test account credentials with us for our investigation. We shall look into it and assist you further.

// Register callback method for SSL validation event
ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidationHandler;

// This event handler is called when SSL certificate is verified
private static bool RemoteCertificateValidationHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true; //Ignore the checks and go ahead
}

Hello Muhammad Waqas,

Thank you for your reply.

Yes, your provided suggestion work out. It actually suppress OR switched off certificate validation.

Thank you again !


<span style=“mso-fareast-font-family:“Times New Roman”;mso-fareast-theme-font:minor-fareast;
color:#1F497D;mso-no-proof:yes”><o:p></o:p>

Hi Ashpak,


We are glad to know that your problem is solved. Please feel free to write to us if you have any other query related to the API.