📄 classsmtp.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SMTP class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>SMTP Class Reference</h1><code>#include <<a class="el" href="smtp_8h-source.html">smtp.h</a>></code>
<p>
<p>Inheritance diagram for SMTP:
<p><center><img src="classSMTP.png" usemap="#SMTP_map" border="0"></center>
<map name="SMTP_map">
<area href="classLogger.html" alt="Logger" shape="rect" coords="0,0,52,24">
</map>
<a href="classSMTP-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=2><br><h2>Public Types</h2></td></tr>
<tr><td nowrap align=right valign=top>enum </td><td valign=bottom><a class="el" href="classSMTP.html#s9">AUTH_TYPE</a> { <br>
<b>AUTO</b>,
<b>PLAIN</b>,
<b>LOGIN</b>,
<b>CRAM_MD5</b>,
<br>
<b>CRAM_SHA1</b>,
<b>NO_AUTH</b>
<br>
}</td></tr>
<tr><td nowrap align=right valign=top>enum </td><td valign=bottom><a class="el" href="classSMTP.html#s10">SSL_TYPE</a> { <b>STARTTLS</b>,
<b>SMTPS</b>,
<b>NO_SSL</b>
}</td></tr>
<tr><td colspan=2><br><h2>Public Methods</h2></td></tr>
<tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classSMTP.html#a0">SMTP</a> (const string &<a class="el" href="classSMTP.html#n0">domain</a>, const string &<a class="el" href="classSMTP.html#n1">from</a>, const string &server, unsigned int port)</td></tr>
<tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classSMTP.html#a1">~SMTP</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#a2">addMessage</a> (const string &msg, const vector< string > &rcpts)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#a3">setCredentials</a> (const string &<a class="el" href="classSMTP.html#n4">username</a>, const string &passwd, <a class="el" href="classSMTP.html#s9">AUTH_TYPE</a> <a class="el" href="classSMTP.html#n6">auth_type</a>=SMTP::AUTO)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#a4">setSSLOpts</a> (<a class="el" href="classSMTP.html#s10">SMTP::SSL_TYPE</a> <a class="el" href="classSMTP.html#n7">ssl_type</a>, <a class="el" href="classSSLSocket.html#s2">SSLSocket::SSL_OPTS</a> opts=SSLSocket::VERIFY_PEER, const string &ca_file="", const string &ca_dir="")</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#a5">sendMessage</a> ()</td></tr>
<tr><td colspan=2><br><h2>Protected Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b0">sendHELO</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b1">sendMAILFROM</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b2">sendRCPTTO</a> (Message &msg)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b3">sendDATA</a> (Message &msg)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b4">sendQUIT</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b5">startSSL</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b6">evalResponse</a> (const string &answer, bool is_221_fatal=true)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b7">authenticate</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b8">auth_login</a> (const string &<a class="el" href="classSMTP.html#n4">username</a>, const string &<a class="el" href="classSMTP.html#n5">password</a>)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b9">auth_plain</a> (const string &<a class="el" href="classSMTP.html#n4">username</a>, const string &<a class="el" href="classSMTP.html#n5">password</a>)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b10">auth_cram_md5</a> (const string &<a class="el" href="classSMTP.html#n4">username</a>, const string &<a class="el" href="classSMTP.html#n5">password</a>)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b11">auth_cram_sha1</a> (const string &<a class="el" href="classSMTP.html#n4">username</a>, const string &<a class="el" href="classSMTP.html#n5">password</a>)</td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSMTP.html#b12">read_response</a> (bool is_221_fatal=true)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSMTP.html#b13">check_auth_method</a> (const string &response, const string &<a class="el" href="classSMTP.html#n6">auth_type</a>)</td></tr>
<tr><td nowrap align=right valign=top><a class="el" href="classSMTP.html#s9">AUTH_TYPE</a> </td><td valign=bottom><a class="el" href="classSMTP.html#b14">best_auth_method</a> (const string &response)</td></tr>
<tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSMTP.html#n0">domain</a></td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSMTP.html#n1">from</a></td></tr>
<tr><td nowrap align=right valign=top>vector< Message > </td><td valign=bottom><a class="el" href="classSMTP.html#n2">msgs</a></td></tr>
<tr><td nowrap align=right valign=top><a class="el" href="classSSLSocket.html">SSLSocket</a> * </td><td valign=bottom><a class="el" href="classSMTP.html#n3">socket</a></td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSMTP.html#n4">username</a></td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSMTP.html#n5">password</a></td></tr>
<tr><td nowrap align=right valign=top><a class="el" href="classSMTP.html#s9">AUTH_TYPE</a> </td><td valign=bottom><a class="el" href="classSMTP.html#n6">auth_type</a></td></tr>
<tr><td nowrap align=right valign=top><a class="el" href="classSMTP.html#s10">SSL_TYPE</a> </td><td valign=bottom><a class="el" href="classSMTP.html#n7">ssl_type</a></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
This class implements the SMTP protocol and can be used to send email messages to an SMTP server. It supports ssl encryption as well as different SMTP Auth mechanisms.
<p>
<dl compact><dt><b>
Author: </b><dd>
Timo Benk <<a href="mailto:t_benk@web.de">t_benk@web.de</a>> </dl>
<p>
<hr><h2>Member Enumeration Documentation</h2>
<a name="s9" doxytag="SMTP::AUTH_TYPE"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> enum SMTP::AUTH_TYPE
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
These are the supported SMTP authentication mechanisms. </td>
</tr>
</table>
<a name="s10" doxytag="SMTP::SSL_TYPE"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> enum SMTP::SSL_TYPE
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
The ssl protocol flavor that should be used. This depends on the SMTP server. In general the server uses STARTTLS if it is listening on port 25 and SMTPS if it is listening on port 465. </td>
</tr>
</table>
<hr><h2>Constructor & Destructor Documentation</h2>
<a name="a0" doxytag="SMTP::SMTP"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> SMTP::SMTP </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>domain</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const string & </td>
<td class="mdname" nowrap> <em>from</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const string & </td>
<td class="mdname" nowrap> <em>server</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>unsigned int </td>
<td class="mdname" nowrap> <em>port</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Constructor.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>domain</em> </td><td>
The domain that should be used when sending the HELO cmd. </td></tr>
<tr><td valign=top><em>from</em> </td><td>
The envelope from address. </td></tr>
<tr><td valign=top><em>server</em> </td><td>
The address of the SMTP server. </td></tr>
<tr><td valign=top><em>port</em> </td><td>
The port the SMTP server is listening on. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="a1" doxytag="SMTP::~SMTP"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> SMTP::~SMTP </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Destructor. </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a name="a2" doxytag="SMTP::addMessage"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void SMTP::addMessage </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>msg</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const vector< string > & </td>
<td class="mdname" nowrap> <em>rcpts</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Adds a message to this SMTP session that will be send to the recipicients that are grouped in the vector rcpts when <a class="el" href="classSMTP.html#a5">SMTP::sendMessage</a> is called. This method can be called multiple times to send multiple messages in one SMTP session.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>msg</em> </td><td>
The email msg that should be send, </td></tr>
<tr><td valign=top><em>rcpts</em> </td><td>
The recpicients for that email msg. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="b10" doxytag="SMTP::auth_cram_md5"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void SMTP::auth_cram_md5 </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>username</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const string & </td>
<td class="mdname" nowrap> <em>password</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [protected]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Authenticates the user using the CRAM-MD5 method.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>username</em> </td><td>
The username that should be used for authentication. </td></tr>
<tr><td valign=top><em>passwd</em> </td><td>
The password that should be used for authentication.</td></tr>
</table>
</dl><dl compact><dt><b>
Exceptions: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em><a class="el" href="classTransferException.html">TransferException</a></em> </td><td>
If the SMTP server responds with an error msg. </td></tr>
<tr><td valign=top><em><a class="el" href="classTransferException.html">TransferException</a></em> </td><td>
On any uncommon event that occurs while sending data through the socket. </td></tr>
<tr><td valign=top><em><a class="el" href="classSSLException.html">SSLException</a></em> </td><td>
On any uncommon event that occurs while sending data through the encrypted socket. </td></tr>
<tr><td valign=top><em><a class="el" href="classDecodeException.html">DecodeException</a></em> </td><td>
If the BASE64 data was invalid. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="b11" doxytag="SMTP::auth_cram_sha1"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void SMTP::auth_cram_sha1 </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>username</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const string & </td>
<td class="mdname" nowrap> <em>password</em></td>
</tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -