⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smtp_8h-source.html

📁 LINUX下发送邮件的库,测试很好用,有各种发送测试的例子
💻 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.h Source File</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> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </center>
<hr><h1>smtp.h</h1><div class="fragment"><pre>00001 <font class="comment">/*************************************************************************</font>
00002 <font class="comment"> *                                                                       *</font>
00003 <font class="comment"> * This program is free software; you can redistribute it and/or modify  *</font>
00004 <font class="comment"> * it under the terms of the GNU General Public License as published by  *</font>
00005 <font class="comment"> * the Free Software Foundation; either version 2 of the License, or     *</font>
00006 <font class="comment"> * (at your option) any later version.                                   *</font>
00007 <font class="comment"> *                                                                       *</font>
00008 <font class="comment"> *************************************************************************/</font>
00009 
00010 <font class="preprocessor">#ifndef _SMTP_H__</font>
00011 <font class="preprocessor"></font><font class="preprocessor">#define _SMTP_H__</font>
00012 <font class="preprocessor"></font>
00013 <font class="preprocessor">#include "global.h"</font>
00014 <font class="preprocessor">#include "exception.h"</font>
00015 <font class="preprocessor">#include "logger.h"</font>
00016 <font class="preprocessor">#include "i18n.h"</font>
00017 <font class="preprocessor">#include "inetsocket.h"</font>
00018 <font class="preprocessor">#include "algorithm.h"</font>
00019 <font class="preprocessor">#include &lt;unistd.h&gt;</font>
00020 <font class="preprocessor">#include &lt;arpa/inet.h&gt;</font>
00021 <font class="preprocessor">#include &lt;netdb.h&gt;</font>
00022 <font class="preprocessor">#include &lt;sys/socket.h&gt;</font>
00023 <font class="preprocessor">#include &lt;netinet/in.h&gt;</font>
00024 <font class="preprocessor">#include &lt;errno.h&gt;</font>
00025 <font class="preprocessor">#include &lt;string&gt;</font>
00026 
00027 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00028 
<a name="l00037"></a><a class="code" href="classSMTP.html">00037</a> <font class="keyword">class </font><a class="code" href="classSMTP.html">SMTP</a> : <font class="keyword">public</font> <a class="code" href="classLogger.html">Logger</a>
00038 {
00042         <font class="keyword">struct </font>Message
00043         {
00044                 string         msg;
00045                 vector&lt;string&gt; rcpts;
00046         };
00047 
00048         <font class="keyword">public</font>:
<a name="l00052"></a><a class="code" href="classSMTP.html#s9">00052</a>                 <font class="keyword">enum</font> <a class="code" href="classSMTP.html#s9">AUTH_TYPE</a> { AUTO, PLAIN, LOGIN, CRAM_MD5, CRAM_SHA1, NO_AUTH };
00053 
<a name="l00060"></a><a class="code" href="classSMTP.html#s10">00060</a>                 <font class="keyword">enum</font> <a class="code" href="classSMTP.html#s10">SSL_TYPE</a> { STARTTLS, SMTPS, NO_SSL };
00061 
00070                 <a class="code" href="classSMTP.html">SMTP</a>
00071                         ( 
00072                                 <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n0">domain</a>,
00073                                 <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n1">from</a>,
00074                                 <font class="keyword">const</font> string &amp;server,
00075                                 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> port
00076                         );
00077 
00081                 <a class="code" href="classSMTP.html#a1">~SMTP</a> ();
00082 
00093                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#a2">addMessage</a> (<font class="keyword">const</font> string &amp;msg, <font class="keyword">const</font> vector&lt;string&gt; &amp;rcpts);
00094 
00102                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#a3">setCredentials</a>
00103                                                 (
00104                                                         <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n4">username</a>,
00105                                                         <font class="keyword">const</font> string &amp;passwd,
00106                                                         <a class="code" href="classSMTP.html#s9">AUTH_TYPE</a> <a class="code" href="classSMTP.html#n6">auth_type</a> = SMTP::AUTO
00107                                                 );
00108 
00152                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#a4">setSSLOpts</a>
00153                                         ( 
00154                                                 <a class="code" href="classSMTP.html#s10">SMTP::SSL_TYPE</a> <a class="code" href="classSMTP.html#n7">ssl_type</a>,
00155                                                 <a class="code" href="classSSLSocket.html#s2">SSLSocket::SSL_OPTS</a> opts = SSLSocket::VERIFY_PEER, 
00156                                                 <font class="keyword">const</font> string &amp;ca_file    = <font class="stringliteral">""</font>, 
00157                                                 <font class="keyword">const</font> string &amp;ca_dir     = <font class="stringliteral">""</font> 
00158                                         );
00159 
00183                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#a5">sendMessage</a> ();
00184 
00185         <font class="keyword">protected</font>:
<a name="l00189"></a><a class="code" href="classSMTP.html#n0">00189</a>                 string <a class="code" href="classSMTP.html#n0">domain</a>;
00190 
<a name="l00194"></a><a class="code" href="classSMTP.html#n1">00194</a>                 string <a class="code" href="classSMTP.html#n1">from</a>;
00195                 
<a name="l00199"></a><a class="code" href="classSMTP.html#n2">00199</a>                 vector&lt;Message&gt; <a class="code" href="classSMTP.html#n2">msgs</a>;
00200 
<a name="l00204"></a><a class="code" href="classSMTP.html#n3">00204</a>                 <a class="code" href="classSSLSocket.html">SSLSocket</a> * <a class="code" href="classSMTP.html#n3">socket</a>;
00205 
<a name="l00209"></a><a class="code" href="classSMTP.html#n4">00209</a>                 string <a class="code" href="classSMTP.html#n4">username</a>;
00210 
<a name="l00214"></a><a class="code" href="classSMTP.html#n5">00214</a>                 string <a class="code" href="classSMTP.html#n5">password</a>;
00215 
<a name="l00219"></a><a class="code" href="classSMTP.html#n6">00219</a>                 <a class="code" href="classSMTP.html#s9">AUTH_TYPE</a> <a class="code" href="classSMTP.html#n6">auth_type</a>;
00220 
<a name="l00224"></a><a class="code" href="classSMTP.html#n7">00224</a>                 <a class="code" href="classSMTP.html#s10">SSL_TYPE</a> <a class="code" href="classSMTP.html#n7">ssl_type</a>;
00225                 
00238                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b0">sendHELO</a> ();
00239 
00252                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b1">sendMAILFROM</a> ();
00253 
00268                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b2">sendRCPTTO</a> (Message &amp;msg);
00269 
00284                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b3">sendDATA</a> (Message &amp;msg);
00285 
00298                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b4">sendQUIT</a> ();
00299 
00314                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b5">startSSL</a> ();
00315 
00330                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b6">evalResponse</a> (<font class="keyword">const</font> string &amp;answer, <font class="keywordtype">bool</font> is_221_fatal = <font class="keyword">true</font>);
00331 
00349                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b7">authenticate</a> ();
00350 
00366                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b8">auth_login</a> (<font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n4">username</a>, <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n5">password</a>);
00367 
00383                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b9">auth_plain</a> (<font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n4">username</a>, <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n5">password</a>);
00384 
00402                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b10">auth_cram_md5</a> (<font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n4">username</a>, <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n5">password</a>);
00403 
00421                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b11">auth_cram_sha1</a> (<font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n4">username</a>, <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n5">password</a>);
00422 
00438                 string <a class="code" href="classSMTP.html#b12">read_response</a> (<font class="keywordtype">bool</font> is_221_fatal = <font class="keyword">true</font>);
00439 
00452                 <font class="keywordtype">void</font> <a class="code" href="classSMTP.html#b13">check_auth_method</a> (<font class="keyword">const</font> string &amp;response, <font class="keyword">const</font> string &amp;<a class="code" href="classSMTP.html#n6">auth_type</a>);
00453 
00461                 <a class="code" href="classSMTP.html#s9">AUTH_TYPE</a> <a class="code" href="classSMTP.html#b14">best_auth_method</a> (<font class="keyword">const</font> string &amp;response);
00462 };
00463 
00464 <font class="preprocessor">#endif</font>
00465 <font class="preprocessor"></font>
</pre></div><hr><address align="right"><small>Generated on Tue Jan 28 17:09:58 2003 by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>

⌨️ 快捷键说明

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