ultimatepp/reference/SMTP/SMTP.cpp
cxl 1e966563a5 .reference: SMTP comment
git-svn-id: svn://ultimatepp.org/upp/trunk@5475 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2012-10-25 06:31:20 +00:00

35 lines
804 B
C++

#include <Core/SMTP/SMTP.h>
using namespace Upp;
// This example requires OpenSSL library installed in win32!
CONSOLE_APP_MAIN
{
// Smtp::Trace();
for(;;) {
Cout() << "Send email to: ";
String to = ReadStdIn();
if(IsNull(to))
break;
Cout() << "Your full email address: ";
String user = ReadStdIn();
Cout() << "Your Gmail password: ";
String pwd = ReadStdIn();
Smtp mail;
mail.Host("smtp.gmail.com")
.Port(465)
.SSL();
mail
.Auth(user, pwd)
.To(to)
.Subject("Test message")
.Body("Hello world!")
.Attach("somedata.txt", "This is a test of String attachement")
.AttachFile(GetDataFile("SMTP.cpp"));
if(mail.Send())
Cout() << "OK\n";
else
Cout() << "Failed: " << mail.GetError() << '\n';
}
}