rt-thread-official/components/net/uip/doc/html/a00161.html

258 lines
15 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: SMTP E-mail sender</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>SMTP E-mail sender<br>
<small>
[<a class="el" href="a00143.html">Applications</a>]</small>
</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
The Simple Mail Transfer Protocol (SMTP) as defined by RFC821 is the standard way of sending and transfering e-mail on the Internet.
<p>
This simple example implementation is intended as an example of how to implement protocols in uIP, and is able to send out e-mail but has not been extensively tested.
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Files</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00105.html">smtp.h</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">SMTP header file. <br></td></tr>
<p>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00104.html">smtp.c</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">SMTP example implementation. <br></td></tr>
<p>
<tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00085.html">smtp_state</a></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g029256bc17a12e1e86781887e11c0c7d"></a><!-- doxytag: member="smtp::SMTP_ERR_OK" ref="g029256bc17a12e1e86781887e11c0c7d" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g029256bc17a12e1e86781887e11c0c7d">SMTP_ERR_OK</a>&nbsp;&nbsp;&nbsp;0</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Error number that signifies a non-error condition. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gcff75c8c930abd6ff168e85373a4eb92"></a><!-- doxytag: member="smtp::SMTP_SEND" ref="gcff75c8c930abd6ff168e85373a4eb92" args="(to, cc, from, subject, msg)" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#gcff75c8c930abd6ff168e85373a4eb92">SMTP_SEND</a>(to, cc, from, subject, msg)&nbsp;&nbsp;&nbsp;smtp_send(to, cc, from, subject, msg, strlen(msg))</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g3212e70c55244608ac16316888c354f0"></a><!-- doxytag: member="smtp::ISO_nl" ref="g3212e70c55244608ac16316888c354f0" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>&nbsp;&nbsp;&nbsp;0x0a</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g6cda47c85ce1b58b501b44ac9cccc50e"></a><!-- doxytag: member="smtp::ISO_cr" ref="g6cda47c85ce1b58b501b44ac9cccc50e" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g6cda47c85ce1b58b501b44ac9cccc50e">ISO_cr</a>&nbsp;&nbsp;&nbsp;0x0d</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gf7dd2757d1e766f65b01ba7c91c660a0"></a><!-- doxytag: member="smtp::ISO_period" ref="gf7dd2757d1e766f65b01ba7c91c660a0" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#gf7dd2757d1e766f65b01ba7c91c660a0">ISO_period</a>&nbsp;&nbsp;&nbsp;0x2e</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g34b924954ba5707d536df28d71a80d39"></a><!-- doxytag: member="smtp::ISO_2" ref="g34b924954ba5707d536df28d71a80d39" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g34b924954ba5707d536df28d71a80d39">ISO_2</a>&nbsp;&nbsp;&nbsp;0x32</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g9e97c58fe35f750ad192774be9408ac8"></a><!-- doxytag: member="smtp::ISO_3" ref="g9e97c58fe35f750ad192774be9408ac8" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g9e97c58fe35f750ad192774be9408ac8">ISO_3</a>&nbsp;&nbsp;&nbsp;0x33</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g28cf9765e4b57451af559ab988ad7160"></a><!-- doxytag: member="smtp::ISO_4" ref="g28cf9765e4b57451af559ab988ad7160" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g28cf9765e4b57451af559ab988ad7160">ISO_4</a>&nbsp;&nbsp;&nbsp;0x34</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g17ccd786400fd08b941e11046df1668f"></a><!-- doxytag: member="smtp::ISO_5" ref="g17ccd786400fd08b941e11046df1668f" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g17ccd786400fd08b941e11046df1668f">ISO_5</a>&nbsp;&nbsp;&nbsp;0x35</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a> (unsigned char error)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Callback function that is called when an e-mail transmission is done. <a href="#gb1fc692a2700b7a51517724364683f67"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g64807ba7c221ddf735572d05021539f2"></a><!-- doxytag: member="smtp::smtp_init" ref="g64807ba7c221ddf735572d05021539f2" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g64807ba7c221ddf735572d05021539f2">smtp_init</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gbc331f73107958428bf1c392ba19b6f4"></a><!-- doxytag: member="smtp::smtp_appcall" ref="gbc331f73107958428bf1c392ba19b6f4" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#gbc331f73107958428bf1c392ba19b6f4">smtp_appcall</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#g37e3103b9591790d484a450525739661">smtp_configure</a> (char *lhostname, void *server)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Specificy an SMTP server and hostname. <a href="#g37e3103b9591790d484a450525739661"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned char&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00161.html#gf0349a8481565e80f55a751e2b408d6d">smtp_send</a> (char *to, char *cc, char *from, char *subject, char *msg, <a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> msglen)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Send an e-mail. <a href="#gf0349a8481565e80f55a751e2b408d6d"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g37e3103b9591790d484a450525739661"></a><!-- doxytag: member="smtp.c::smtp_configure" ref="g37e3103b9591790d484a450525739661" args="(char *lhostname, void *server)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">void smtp_configure </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">char *&nbsp;</td>
<td class="mdname" nowrap> <em>lhostname</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>void *&nbsp;</td>
<td class="mdname" nowrap> <em>server</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Specificy an SMTP server and hostname.
<p>
This function is used to configure the SMTP module with an SMTP server and the hostname of the host.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>lhostname</em>&nbsp;</td><td>The hostname of the uIP host.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>server</em>&nbsp;</td><td>A pointer to a 4-byte array representing the IP address of the SMTP server to be configured. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00174.html#l00216">216</a> of file <a class="el" href="a00174.html">smtp.c</a>.
<p>
References <a class="el" href="a00202.html#l00882">uip_ipaddr_copy</a>. </td>
</tr>
</table>
<a class="anchor" name="gb1fc692a2700b7a51517724364683f67"></a><!-- doxytag: member="smtp.h::smtp_done" ref="gb1fc692a2700b7a51517724364683f67" args="(unsigned char error)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">void smtp_done </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">unsigned char&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>error</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Callback function that is called when an e-mail transmission is done.
<p>
This function must be implemented by the module that uses the SMTP module.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>error</em>&nbsp;</td><td>The number of the error if an error occured, or SMTP_ERR_OK. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00038.html#a170">smtp.c</a>, and <a class="el" href="a00039.html#a195">smtp.h</a>.</dl>
<p>
Referenced by <a class="el" href="a00174.html#l00190">smtp_appcall()</a>. </td>
</tr>
</table>
<a class="anchor" name="gf0349a8481565e80f55a751e2b408d6d"></a><!-- doxytag: member="smtp.c::smtp_send" ref="gf0349a8481565e80f55a751e2b408d6d" args="(char *to, char *cc, char *from, char *subject, char *msg, u16_t msglen)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">unsigned char smtp_send </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">char *&nbsp;</td>
<td class="mdname" nowrap> <em>to</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>char *&nbsp;</td>
<td class="mdname" nowrap> <em>cc</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>char *&nbsp;</td>
<td class="mdname" nowrap> <em>from</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>char *&nbsp;</td>
<td class="mdname" nowrap> <em>subject</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>char *&nbsp;</td>
<td class="mdname" nowrap> <em>msg</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a>&nbsp;</td>
<td class="mdname" nowrap> <em>msglen</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Send an e-mail.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>to</em>&nbsp;</td><td>The e-mail address of the receiver of the e-mail. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>cc</em>&nbsp;</td><td>The e-mail address of the CC: receivers of the e-mail. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>from</em>&nbsp;</td><td>The e-mail address of the sender of the e-mail. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>subject</em>&nbsp;</td><td>The subject of the e-mail. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>msg</em>&nbsp;</td><td>The actual e-mail message. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>msglen</em>&nbsp;</td><td>The length of the e-mail message. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00174.html#l00233">233</a> of file <a class="el" href="a00174.html">smtp.c</a>.
<p>
References <a class="el" href="a00175.html#l00084">smtp_state::from</a>, <a class="el" href="a00202.html#l01070">HTONS</a>, <a class="el" href="a00175.html#l00086">smtp_state::msg</a>, <a class="el" href="a00175.html#l00087">smtp_state::msglen</a>, <a class="el" href="a00172.html#l00069">NULL</a>, <a class="el" href="a00193.html#l00144">PSOCK_INIT</a>, <a class="el" href="a00175.html#l00085">smtp_state::subject</a>, <a class="el" href="a00175.html#l00083">smtp_state::to</a>, and <a class="el" href="a00201.html#l00407">uip_connect()</a>. </td>
</tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>