Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
добавил примеры
Browse files Browse the repository at this point in the history
  • Loading branch information
imnetcat committed Sep 11, 2020
1 parent 814f5e6 commit 4cf8fa5
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/smtpclient_easy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../release/cout.hpp"
using namespace Cout::Network;

#include <iostream>
using namespace std;

int main()
{
SMTPClient client;

Protocol::SMTP::MAIL mail;
mail.SetSenderName("User");
mail.SetSenderMail("[email protected]");
mail.SetReplyTo("[email protected]");
mail.SetSubject("Testing"); // title of mail

try
{
mail.AddRecipient("[email protected]");


mail.AddMsgLine("Hello world!");

client.SetServer(Protocol::SMTP::Server::ID::GMAIL_TLS);
client.SetLogin("[email protected]");
client.SetPassword("********************************");

client.Send(&mail);
}
catch (const Cout::Exceptions::base& exc)
{
cerr << "[ERROR] " << exc.what() << endl
<< "\t\t" << exc.when() << endl;
}

return 0;
}
61 changes: 61 additions & 0 deletions examples/smtpclient_midl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "../release/cout.hpp"
using namespace Cout::Network;

#include <iostream>
using namespace std;

int main()
{
SMTPClient client;

Protocol::SMTP::MAIL mail;
mail.SetSenderName("User");
mail.SetSenderMail("[email protected]");
mail.SetReplyTo("[email protected]");
mail.SetSubject("Testing"); // title of mail

try
{
mail.AddAttachment("../some/path/to/file.txt");
mail.AddAttachment("../some/path/to/file.jpg");
mail.AddAttachment("../some/path/to/file.pdf");
mail.AddAttachment("../some/path/to/file.zip");

mail.AddRecipient("[email protected]");
mail.AddRecipient("[email protected]");
mail.AddRecipient("[email protected]");
mail.AddRecipient("[email protected]");

mail.AddCCRecipient("[email protected]");
mail.AddCCRecipient("[email protected]");
mail.AddCCRecipient("[email protected]");

mail.AddBCCRecipient("[email protected]");
mail.AddBCCRecipient("[email protected]");
mail.AddBCCRecipient("[email protected]");
mail.AddBCCRecipient("[email protected]");


mail.AddMsgLine("Hello world!");
mail.AddMsgLine("...");
mail.AddMsgLine("This is worked!");
mail.AddMsgLine("...");

// edit the mail msb body
mail.ModMsgLine(1, ""); // line indexed from 0
mail.ModMsgLine(3, "Regargs");

client.SetServer(Protocol::SMTP::Server::ID::GMAIL_TLS);
client.SetLogin("[email protected]");
client.SetPassword("********************************");

client.Send(&mail);
}
catch (const Cout::Exceptions::base& exc)
{
cerr << "[ERROR] " << exc.what() << endl
<< "\t\t" << exc.when() << endl;
}

return 0;
}

0 comments on commit 4cf8fa5

Please sign in to comment.