mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-11 22:03:09 -06:00
reference: SMTP
git-svn-id: svn://ultimatepp.org/upp/trunk@4844 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b0b10b8ea4
commit
f2ed74f8b9
3 changed files with 52 additions and 0 deletions
33
reference/SMTP/SMTP.cpp
Normal file
33
reference/SMTP/SMTP.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include <Core/SMTP/SMTP.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
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")
|
||||
.Text("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';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue