This property specifies whether current connection uses STARTTLS command to enable SSL/TLS.
| Value | Meaning |
| 0 | Direct SSL/TLS |
| 1 | STARTTLS(default) |
Usually, there are two ways to deploy SMTP server to SSL/TLS, one is deploying SMTP port as direct SSL/TLS connection, another way is switching connection from normal channel to SSL/TLS channel by STARTTLS command(rfc 2487). Therefore, you should choose the appropriate value for SSL_starttls property upon your SMTP server configuration.
Usage Example:
[Visual Basic]'connect SSL/TLS by STARTTLS command Dim oSmtp As AOSMTPLib.Mail Set oSmtp = new AOSMTPLib.Mail 'Before using Mail, RegisterKey must be assigned. oSmtp.RegisterKey = "your license code" oSmtp.SSL_registerkey = "your SSL/TLS license code" If oSmtp.SSL_init() <> 0 Then MsgBox "initialize ansslplus failed" End If oSmtp.SSL_starttls = 1 oSmtp.Subject = "test for ssl" oSmtp.BodyText = "test body" oSmtp.FromAddr = "test@adminsystem.net" oSmtp.AddRecipient "Support Team", "Support@AdminSystem.NET", 0 If oSmtp.SendMail() = 0 Then MsgBox "Message delivered" Else MsgBox oSmtp.GetLastErrDescription() End If oSmtp.SSL_uninit()
'connect SSL/TLS by direct SSL/TLS Dim oSmtp As AOSMTPLib.Mail Set oSmtp = new AOSMTPLib.Mail 'Before using Mail, RegisterKey must be assigned. oSmtp.RegisterKey = "your license code" oSmtp.SSL_registerkey = "your SSL/TLS license code" If oSmtp.SSL_init() <> 0 Then MsgBox "initialize ansslplus failed" End If oSmtp.SSL_starttls = 0 'SMTP server usually uses 465 as the alone SSL/TLS port oSmtp.ServerPort = 465 oSmtp.Subject = "test for ssl" oSmtp.BodyText = "test body" oSmtp.FromAddr = "test@adminsystem.net" oSmtp.AddRecipient "Support Team", "Support@AdminSystem.NET", 0 If oSmtp.SendMail() = 0 Then MsgBox "Message delivered" Else MsgBox oSmtp.GetLastErrDescription() End If oSmtp.SSL_uninit()[C#]
//connect SSL/TLS by STARTTLS command
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
//Before using Mail, RegisterKey must be assigned.
oSmtp.RegisterKey = "your license code";
oSmtp.SSL_registerkey = "your SSL/TLS license code";
if( oSmtp.SSL_init() != 0 )
{
Console.WriteLine( "initialize ansslplus failed" );
}
oSmtp.SSL_starttls = 1;
oSmtp.Subject = "test for ssl";
oSmtp.BodyText = "test body";
oSmtp.FromAddr = "test@adminsystem.net";
oSmtp.AddRecipient("Support Team", "Support@AdminSystem.NET", 0);
if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message delivered" );
else
Console.WriteLine( oSmtp.GetLastErrDescription());
oSmtp.SSL_uninit();
//connect SSL/TLS by direct SSL/TLS port
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
//Before using Mail, RegisterKey must be assigned.
oSmtp.RegisterKey = "your license code";
oSmtp.SSL_registerkey = "your SSL/TLS license code";
if( oSmtp.SSL_init() != 0 )
{
Console.WriteLine( "initialize ansslplus failed" );
}
oSmtp.SSL_starttls = 0;
//SMTP server usually uses 465 as the alone SSL/TLS port
oSmtp.ServerPort = 465;
oSmtp.Subject = "test for ssl";
oSmtp.BodyText = "test body";
oSmtp.FromAddr = "test@adminsystem.net";
oSmtp.AddRecipient("Support Team", "Support@AdminSystem.NET", 0);
if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message delivered" );
else
Console.WriteLine( oSmtp.GetLastErrDescription());
oSmtp.SSL_uninit();
See Also
2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.