testsmailer.cpp

来自「邮件发送原理的实现」· C++ 代码 · 共 46 行

CPP
46
字号
///////////////////////////////////////////////////////////////////// This program is a demostration about how to use SMailer.// Written by Morning, mailto:moyingzz@etang.com//// Date:2003-5///////////////////////////////////////////////////////////////////#include <iostream>#include "SMailer.h"#include "../MUtils/WinSockHelper.h"void main(){    MUtils::WinSockHelper wshelper;    // make sure the file 'boot.ini' is in the root directory on driver C    SMailer::TextPlainContent  content1("plain text content");    SMailer::TextHtmlContent   content2("<a href='http://morningspace.51.net'>click me</a>");    SMailer::AppOctStrmContent content3("c:\\boot.ini");    SMailer::MailInfo info;    info.setSenderName("morning");    info.setSenderAddress("moyingzz@etang.com");    info.addReceiver("friend1", "friend1@etang.com");    info.addReceiver("friend2", "friend2@etang.com");    info.setPriority(SMailer::Priority::normal);    info.setSubject("a test mail");    info.addMimeContent(&content1);    info.addMimeContent(&content2);    info.addMimeContent(&content3);    try    {        SMailer::MailSender sender("smtp.etang.com", "username", "password");        sender.setMail(&SMailer::MailWrapper(&info));        sender.sendMail();    }    catch (SMailer::MailException& e)    {        std::cout << e.what() << std::endl;    }    catch (...)    {        std::cout << "Unkown error" << std::endl;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?