Unicode C++
Unicode C++
Send email using SMTP STARTTLS.
Send email using SMTP STARTTLS. With STARTTLS, the SMTP client connects to the SMTP server on port 25 (non-SSL) and then issues a STARTTLS command to convert the connection to a secure TLS channel.Chilkat Unicode C++ Downloads
#include <CkMailManW.h>
#include <CkEmailW.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The mailman object is used for sending and receiving email.
CkMailManW mailman;
// Set the SMTP server.
mailman.put_SmtpHost(L"smtp.mymailserver.com");
mailman.put_SmtpUsername(L"myLogin");
mailman.put_SmtpPassword(L"myPassword");
mailman.put_StartTLS(true);
// Create a new email object
CkEmailW email;
email.put_Subject(L"This is a test");
email.put_Body(L"This is a test");
email.put_From(L"Chilkat Support <support@chilkatsoft.com>");
success = email.AddTo(L"Chilkat Admin",L"admin@chilkatsoft.com");
success = mailman.SendEmail(email);
if (success != true) {
wprintf(L"%s\n",mailman.lastErrorText());
return;
}
success = mailman.CloseSmtpConnection();
if (success != true) {
wprintf(L"Connection to SMTP server not closed cleanly.\n");
}
wprintf(L"Mail Sent!\n");
}