<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Wt: Wt::Mail::Client Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceWt.html">Wt</a> </li> <li class="navelem"><a class="el" href="namespaceWt_1_1Mail.html">Mail</a> </li> <li class="navelem"><a class="el" href="classWt_1_1Mail_1_1Client.html">Client</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> </div> <div class="headertitle"> <div class="title">Wt::Mail::Client Class Reference<div class="ingroups"><a class="el" href="group__mail.html">SMTP client library (Wt::Mail)</a></div></div> </div> </div> <div class="contents"> <!-- doxytag: class="Wt::Mail::Client" --> <p>An SMTP mail client. <a href="classWt_1_1Mail_1_1Client.html#details">More...</a></p> <p><code>#include <Wt/Mail/Client></code></p> <p><a href="classWt_1_1Mail_1_1Client-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Mail_1_1Client.html#a564f5bfd10f9ae1c4c783c9e8a6b54a0">Client</a> (const std::string &selfHost=std::string())</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#a564f5bfd10f9ae1c4c783c9e8a6b54a0"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Mail_1_1Client.html#ab28a973133a812d556e121a5020be932">~Client</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#ab28a973133a812d556e121a5020be932"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Mail_1_1Client.html#a25527078ad8fdc02707f09623da61c85">connect</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Connects to the default SMTP server. <a href="#a25527078ad8fdc02707f09623da61c85"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Mail_1_1Client.html#af7bf43e793d265034c6cb343636b4024">connect</a> (const std::string &smtpHost, int smtpPort=25)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Connects to a given STMP server and port. <a href="#af7bf43e793d265034c6cb343636b4024"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa48da8e0c3e301da9d2ca8e566ea83f8"></a><!-- doxytag: member="Wt::Mail::Client::disconnect" ref="aa48da8e0c3e301da9d2ca8e566ea83f8" args="()" --> void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Mail_1_1Client.html#aa48da8e0c3e301da9d2ca8e566ea83f8">disconnect</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Disconnects the client from the SMTP server. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Mail_1_1Client.html#a324329dd4ed8d2e5e8c7061399bcbfd1">send</a> (const <a class="el" href="classWt_1_1Mail_1_1Message.html">Message</a> &message)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Sends a message. <a href="#a324329dd4ed8d2e5e8c7061399bcbfd1"></a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>An SMTP mail client. </p> <p>The SMTP client can send one or more mail messages to an SMTP host.</p> <div class="fragment"><pre class="fragment"><span class="preprocessor"> #include <Wt/Mail/Client></span> <span class="preprocessor"> #include <Wt/Mail/Message></span> Mail::Message message; message.setFrom(Mail::Mailbox(<span class="stringliteral">"kudos@corp.org"</span>, <span class="stringliteral">"Kudos Dukos"</span>); message.addRecipient(<a class="code" href="namespaceWt_1_1Mail.html#a787e77713f5f302a3bbba194ee2a1c3bac7b27436efb9a02e0f4cac93e2efb380" title="To: recipient.">Mail::To</a>, Mail::Mailbox(<span class="stringliteral">"koen@emweb.be"</span>, <span class="stringliteral">"Koen Deforche"</span>); message.setSubject(<span class="stringliteral">"Hey there, koen!"</span>); message.setBody(<span class="stringliteral">"That mail client seems to be working."</span>); message.addHtmlBody (<span class="stringliteral">"<p>"</span> <span class="stringliteral">"<a href=\"http://www.webtoolkit.eu/wt\">That mail client</a>"</span> <span class="stringliteral">" seems to be working just great!</p>"</span>); Mail::Client client; client.connect(<span class="stringliteral">"localhost"</span>); client.send(message); </pre></div><p>Only the bare essentials of the SMTP protocol are current implemented, although the <a class="el" href="classWt_1_1Mail_1_1Message.html" title="A mail message.">Message</a> itself supports proper unicode handling.</p> <dl class="note"><dt><b>Note:</b></dt><dd>Currently only a plain-text SMTP protocol is supported. SSL transport will be added in the future.</dd> <dd> Currently the client sends an email synchronously, and thus a slow connection to the SMTP server may block the current thread. We plan to change this in the future. It is thus beneficial to connect to a local SMTP daemon to minimize this deficiency. </dd></dl> </div><hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a564f5bfd10f9ae1c4c783c9e8a6b54a0"></a><!-- doxytag: member="Wt::Mail::Client::Client" ref="a564f5bfd10f9ae1c4c783c9e8a6b54a0" args="(const std::string &selfHost=std::string())" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Wt::Mail::Client::Client </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>selfHost</em> = <code>std::string()</code></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Constructor. </p> <p>The <code>selfHost</code> is how the mail client will identify itself to the mail server, in the EHLO command.</p> <p>If not defined, the "smtp-self-host" configuration property is used, and if that property is not defined, it defaults to "localhost". </p> </div> </div> <a class="anchor" id="ab28a973133a812d556e121a5020be932"></a><!-- doxytag: member="Wt::Mail::Client::~Client" ref="ab28a973133a812d556e121a5020be932" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Wt::Mail::Client::~Client </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Destructor. </p> <p>If the client is still connected, this disconnects the client. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a25527078ad8fdc02707f09623da61c85"></a><!-- doxytag: member="Wt::Mail::Client::connect" ref="a25527078ad8fdc02707f09623da61c85" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Wt::Mail::Client::connect </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Connects to the default SMTP server. </p> <p>This connects to the SMTP server defined by the "smtp-host" property, on port defined by the "smtp-port" property. If these properties are not set, "localhost" and 25 are used as defaults respectively.</p> <p>Returns whether the connection could be established and the SMTP hand-shake was successful. </p> </div> </div> <a class="anchor" id="af7bf43e793d265034c6cb343636b4024"></a><!-- doxytag: member="Wt::Mail::Client::connect" ref="af7bf43e793d265034c6cb343636b4024" args="(const std::string &smtpHost, int smtpPort=25)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Wt::Mail::Client::connect </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"><em>smtpHost</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>smtpPort</em> = <code>25</code> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Connects to a given STMP server and port. </p> <p>Returns whether the connection could be established and the SMTP hand-shake was successful. </p> </div> </div> <a class="anchor" id="a324329dd4ed8d2e5e8c7061399bcbfd1"></a><!-- doxytag: member="Wt::Mail::Client::send" ref="a324329dd4ed8d2e5e8c7061399bcbfd1" args="(const Message &message)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Wt::Mail::Client::send </td> <td>(</td> <td class="paramtype">const <a class="el" href="classWt_1_1Mail_1_1Message.html">Message</a> & </td> <td class="paramname"><em>message</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Sends a message. </p> <p>The client must be connected before messages can be sent. </p> </div> </div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>