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

📄 smtp.htm

📁 VC++实现网络POP3协议的MFC扩展
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<html>

<head>
<title>CSMTPConnection v1.35</title>
</head>

<body bgcolor="#FFFFFF">

<p align="left"><img src="smtp.gif" width="39" height="38" alt="smtp.gif (295 bytes)"><font
face="Arial"><strong><big><big><big><big>CSMTPConnection v1.35</big></big></big></big></strong></font></p>

<p><font face="Arial">Welcome to <strong>CSMTPConnection</strong>, a freeware MFC class to
support the SMTP protocol. SMTP for those not familiar with all the internet protocols is
the protocol used to send internet email.</font></p>

<p><font face="Arial">For detailed information about the <strong>S</strong>imple <strong>M</strong>ail
<strong>T</strong>ransfer <strong>P</strong>rotocol you should read RFC 821, </font></p>

<p><font face="Arial">Other documents that these classes refer to are RFC 2045 (which
defines how MIME attachments are to be handled in a standard SMTP message) and
RFC 822 (which defines the way standard headers which SMTP uses). </font></p>

<p><font face="Arial">You can find numerous Web Servers which carry these documents by
going to <a href="http://www.yahoo.com">www.yahoo.com</a> and look for RFC and 821,
822 or
2045. </font></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<table>
  <tr>
    <td><font face="Arial"><a href="#Features">Features</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#Usage">Usage</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#History">History</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#APIReference">API Reference</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#Enhancements">Planned Enhancements</a></font></td>
  </tr>
  <tr>
    <td><font face="Arial"><a href="#Contact">Contacting the Author</a></font></td>
  </tr>
</table>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><font face="Arial"><a name="Features"></a><big><strong><big>Features</big></strong></big>
</font>

<ul>
  <li><font color="#000000" size="3" face="Arial">Simple and clean C++ interface.</font></li>
  <li><font color="#000000" size="3" face="Arial">The interface provided is synchronous which
    provides an easier programming model than using asynchronous sockets.</font></li>
  <li><font color="#000000" size="3" face="Arial">The code does not rely on the MFC socket
    classes. These classes have a number of shortcomings, one of which causes problems when
    they are used in NT services.</font></li>
  <li><font color="#000000" size="3" face="Arial">The code can be used in a console
    application without any problems (Again this is not the case for the MFC socket classes).</font></li>
  <li><font color="#000000" size="3" face="Arial">A configurable timeout for the connection
    can be set through the class API.</font></li>
  <li><font color="#000000" size="3" face="Arial">The classes are fully Unicode compliant and
    include Unicode built options in the workspace file.</font></li>
  <li><font color="#000000" size="3" face="Arial">As of v1.1, the classes now fully supports
    sending file attachments.</font></li>
  <li><font color="#000000" size="3" face="Arial">Multi CC, BCC &amp; Reply To support is
    included.</font></li>
  <li><font color="#000000" size="3" face="Arial">Support for regular email address formats
    and multiple email address parsing.</font></li>
</ul>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><a name="Usage"></a><font face="Arial"><big><big><strong>Usage</strong></big></big></font>

<ul>
  <li><font color="#000000" size="3" face="Arial">To use the class in your code simply include
    smtp.cpp in your project and #include smtp.h in which ever of your modules needs to make
    calls to the class.</font></li>
  <li><font face="Arial">Your code will need to include MFC either statically or dynamically.</font></li>
  <li><font face="Arial">You will need to have a functioning winsock stack installed and
    correctly initialised prior to calling any functions in CSMTPConnection. Depending on your
    application, this will involve calling either WSAStartup or AfxSocketInit at startup of
    your application.</font></li>
  <li><font face="Arial">You will also need to have afxtempl.h ,winsock.h or afxsock.h and
    afxpriv.h in your precompiled header. The code will work just aswell in a GUI or console
    app. The code should also work in a multithreaded application, although it has not be
    explicitly tested in this scenario.</font></li>
  <li><font face="Arial">To see the class in action, have a look at the code in InitInstance
    in the module &quot;main.cpp&quot;.&nbsp; For example to send a message to the author
    about this class, the code would look something like this (ignoring error handling):</font></li>
</ul>

<p><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSMTPConnection
smtp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; smtp.Connect(&quot;mail.someisp.com&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSMTPMessage m;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
m.AddRecipient(CSMTPAddress(&quot;pjn@indigo.ie&quot;));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m.m_From =
CSMTPAddress(&quot;adeveloper@someisp.com&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m.m_sSubject = &quot;A Fellow developer!&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m.AddBody(&quot;if you can read this then the
CSMTPConnection code is working&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; smtp.SendMessage(m);<br>
</font></p>

<p><font face="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To send your autoexec.bat
as a file attachment to me you would use the following code:</font></p>

<p><font face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSMTPConnection
smtp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; smtp.Connect(&quot;mail.yourisp.com&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSMTPMessage m;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
m.AddRecipient(CSMTPAddress(&quot;pjn@indigo.ie&quot;));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m.m_From =
CSMTPAddress(&quot;you@someisp.com&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m.m_sSubject = &quot;Here's my autoexec.bat
file!&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSMTPAttachment a;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.Attach(&quot;c:\\autoexec.bat&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m.AddAttachment(&amp;a);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; smtp.SendMessage(m);<br>
</font></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><font face="Arial"><big><a name="History"></a></big><font color="#000000" size="5"><strong>History</strong></font></font></p>

<p><strong><font color="#000000" size="3" face="Arial">V1.0 (26th M</font><font
face="Arial"><font size="3"><font color="#000000">ay</font></font><font color="#000000"
size="3"> 1998)</font></font></strong> 

<ul>
  <li><font face="Arial" color="#000000" size="3">Initial public release.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.1 (17th June 1998)</strong></font>

<ul>
  <li><font face="Arial">Fixed the case where a single dot occurs on its own in the body of a
    message</font></li>
  <li><font face="Arial">Classes now supports an optional &quot;Reply-To&quot; Header Field</font></li>
  <li><font face="Arial">Classes now fully supports file attachments</font></li>
  <li><font face="Arial">Some rework on the contents of the help file</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.11 (18th June 1998)</strong></font>

<ul>
  <li><font face="Arial">Fixed a memory overwrite problem which was occurring with the buffer
    used for encoding base64 attachments.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.12 (27th June 1998)</strong></font>

<ul>
  <li><font face="Arial">The case where a line begins with a &quot;.&quot; but contains other
    text is now also catered for. See RFC821, Section 4.5.2 for further details.</font></li>
  <li><font face="Arial">m_sBody in CSMTPMessage has now been made protected. Client
    applications now should call AddBody instead. This ensures that FixSingleDot is only
    called once even if the same message is sent a number of times.</font></li>
  <li><font face="Arial">Fixed a number of problems with how the MIME boundaries were defined
    and sent.</font></li>
  <li><font face="Arial">Got rid of an unreferenced formal parameter compiler warning when
    doing a release build.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.2 (11 August 1998)</strong></font>

<ul>
  <li><font face="Arial">VC 5 project file is now provided instead of VC 4.x</font></li>
  <li><font face="Arial">Attachment array which the message class contains now uses references
    instead of pointers.</font></li>
  <li><font face="Arial">Now uses Sleep(0) to yield our time slice instead of Sleep(100), this
    is the preferred way of writting polling style code in Win32 without serverly impacting
    performance.</font></li>
  <li><font face="Arial">All trace statements now display the value as returned from
    GetLastError</font></li>
  <li><font face="Arial">A number of extra asserts have been added</font></li>
  <li><font face="Arial">AddMultipleRecipients has been added which supports added a number of
    recipients at one time from a single string</font></li>
  <li><font face="Arial">Extra trace statements have been added to help in debugging</font></li>
  <li><font face="Arial">A number of updates to the documentation.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.21 (12 September 1998)</strong></font>

<ul>
  <li><font face="Arial">Removed a couple of unreferenced variable compiler warnings
    discovered when the class was compiled on Visual C++ 6.0.</font></li>
  <li><font face="Arial">Fixed a major bug which was causing an ASSERT when the
    CSMTPAttachment destructor was being called in the InitInstance of the sample app. This
    was inadvertingly introduced for the 1.2 release. The fix is to revert fix 2) as done for
    v1.2. This new fix will also help to reduce the number of attachment images kept in memory
    at one time.</font></li>
  <li><font face="Arial">Fixed a few errors in this help file.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.3 (18 January 1999)</strong></font>

<ul>
  <li><font face="Arial">Full support has now been added for CC (Carbon Copy) &amp; BCC (Blind
    Carbon Copy).</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.31 (22 February 1999)</strong></font>

<ul>
  <li><font face="Arial">Added a Get and SetTitle method which allows a files attachment title
    to be different that the original filename.</font></li>
  <li><font face="Arial">Updated sample app to include a more descriptive subject line.</font></li>
  <li><font face="Arial">Default timeout for the code when a debug build is built has now been
    set to 60 seconds.</font></li>
  <li><font face="Arial">Improved the reading of responses back from the server by
    implementing a growable receive buffer.</font></li>
  <li><font face="Arial">Updated instructions on how the relavent RFC documents can be
    retrieved.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.32 (25 March 1999)</strong></font>

<ul>
  <li><font face="Arial">Now sleeps for 250 ms instead of yielding the time slice. This helps
    reduce CPU usage when waiting for data to arrive in the socket.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.33 (14 May 1999)</strong></font>

<ul>
  <li><font face="Arial">Updated documentation to refer to RFC 822.</font></li>
  <li><font face="Arial">Fixed a bug with the way the code generates time zone
    fields in the Date headers. Thanks to Randy
    A. Scott for reporting this bug.&nbsp;</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.34 (10 September 1999)</strong></font>
<ul>
  <li><font face="Arial">Improved CSMTPMessage::GetHeader to include mime field
    even when no attachments are included.</font></li>
</ul>

<p><font face="Arial" color="#000000" size="3"><strong>V1.35 (5 October 1999)</strong></font>
<ul>
  <li><font face="Arial">Fixed 2 level 4 warnings when compiled using VC 6.</font></li>
</ul>
<p></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p class="crt"><font face="Arial"><a name="APIReference"></a><big><big><strong>API
Reference</strong></big></big></font></p>

<p><font face="Arial">The API consists of the public member functions of the class
CSMTPAddress, CSMTPMessage &amp; CSMTPConnection</font></p>

<p><a href="#CSMTPAddress"><font face="Arial">CSMTPAddress</font></a><br>
<font face="Arial"><a href="#Attach">CSMTPAttachment::Attach</a><br>
<a href="#GetFilename">CSMTPAttachment::GetFilename</a><br>
<a href="#GetEncodedBuffer">CSMTPAttachment::GetEncodedBuffer</a><br>
<a href="#GetEncodedSize">CSMTPAttachment::GetEncodedSize<br>
</a><a href="#SetTitle">CSMTPAttachment::SetTitle<br>
</a><a href="#GetTitle">CSMTPAttachment::GetTitle<br>
</a><a href="#AddRecipient">CSMTPMessage::AddRecipient</a><br>
<a href="#RemoveRecipient">CSMTPMessage::RemoveRecipient</a><br>
<a href="#GetRecipient">CSMTPMessage::GetRecipient</a><br>
<a href="#GetNumberOfRecipients">CSMTPMessage::GetNumberOfRecipients</a><br>
<a href="#AddAttachment">CSMTPMessage::AddAttachment</a><br>
<a href="#RemoveAttachment">CSMTPMessage::RemoveAttachment</a><br>
<a href="#GetAttachment">CSMTPMessage::GetAttachment</a><br>
<a href="#GetNumberOfAttachments">CSMTPMessage::GetNumberOfAttachments</a><br>
<a href="#m_From">CSMTPMessage::m_From</a><br>
<a href="#m_sSubject">CSMTPMessage::m_sSubject</a><br>
<a href="#AddBody">CSMTPMessage::AddBody</a><br>
<a href="#AddMultipleRecipients">CSMTPMessage::AddMultipleRecipients</a><br>
<a href="#m_sXMailer">CSMTPMessage::m_sXMailer</a><br>
<a href="#m_ReplyTo">CSMTPMessage::m_ReplyTo</a><br>
<a href="#Connect">CSMTPConnection::Connect<br>
</a><a href="#Disconnect">CSMTPConnection::Disconnect<br>
</a><a href="#GetLastCommandResponse">CSMTPConnection::GetLastCommandResponse</a><br>
<a href="#GetLastCommandResponseCode">CSMTPConnection::GetLastCommandResponseCode<br>
</a><a href="#GetTimeout">CSMTPConnection::GetTimeout<br>
</a><a href="#SetTimeout">CSMTPConnection::SetTimeout</a><br>
<a href="#SendMessage">CSMTPConnection::SendMessage</a><br>
</font></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><a name="CSMTPAddress" href="#CSMTPAddress"></a><font face="Arial"><big><strong>CSMTPAddress</strong></big></font></p>

<p><font face="Arial"><strong>Remarks</strong></font></p>

<p><font face="Arial">This class is an encapsulation of an address used in sending an
email. It consists of 2 strings namely m_sFriendlyName and m_sEmailAddress. An example of
constructing an address is:</font></p>

<p><font face="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSMTPAddress
a(_T(&quot;pjn@indigo.ie&quot;)); or<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSMTPAddress b(_T(&quot;PJ Naughter&quot;),
_T(&quot;pjn@indigo.ie&quot;));</font></p>

<p><font face="Arial">The second form which includes a friendly address allows it to be
used in &quot;To&quot; and &quot;Reply-To&quot; headers in the form &quot;PJ Naughter
&lt;pjn@indigo.ie&gt;&quot;</font></p>

<p><font face="Arial">One public class method is included called GetRegularFormat which
returns the format just discussed.</font></p>

<p><strong><font face="Arial">See Also</font></strong></p>

⌨️ 快捷键说明

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