NetBurner 3.1
mailto.h
1 /*NB_REVISION*/
2 
3 /*NB_COPYRIGHT*/
4 
13 #ifndef _NB_MAILTO
14 #define _NB_MAILTO
15 
19 #define STATUS_OK (0)
20 #define CONNECT_TO_SMTP_SERVER_FAILED (-1)
21 #define INITIAL_SERVER_REPLY_FAILED (-2)
22 #define HELO_SERVER_REPLY_FAILED (-3)
23 #define MAIL_FROM_SERVER_REPLY_FAILED (-4)
24 #define RCPT_TO_SERVER_REPLY_FAILED (-5)
25 #define DATA_SERVER_REPLY_FAILED (-6)
26 #define DATA_END_SERVER_REPLY_FAILED (-7)
27 #define AUTH_LOGIN_SERVER_REPLY_FAILED (-8)
28 #define USER_ID_SERVER_REPLY_FAILED (-9)
29 #define PASSWORD_SERVER_REPLY_FAILED (-10)
30 #define CONNECT931_SMTP_SERVER_FAILED (-11)
31 
33 /*-------------------------------------------------------------------
34  * Send an email
35  * Returns 0 on failure, 1 on success
36  *------------------------------------------------------------------ */
53 int SendMail(IPADDR smtp_server, /* IP address of the SMTP server */
54  PCSTR userid, /* ASCII String to provide for RFC931 IDentification */
55  PCSTR from_addr, /* From E-Mail address */
56  PCSTR to_addr, /* To E-Mail Address */
57  PCSTR subject, /* E-Mail subject */
58  PCSTR textbody /* E-Mail body */);
59 
60 /*-------------------------------------------------------------------
61  * Send an email with plain text authentication
62  * Returns 0 on failure, 1 on success
63  *-------------------------------------------------------------------*/
87 int SendMailAuth(IPADDR smtp_server, /*IP address of the SMTP server */
88  PCSTR userid, /* ASCII String to provide for RFC931 IDentification */
89  PCSTR pass, /* ASCII String to provide for AUTH IDentification */
90  PCSTR from_addr, /* From E-Mail address */
91  PCSTR to_addr, /* To E-Mail Address */
92  PCSTR subject, /* E-Mail subject */
93  PCSTR textbody /* E-Mail body */);
94 
95 /*-------------------------------------------------------------------
96  * Similar to SendMail() with the following additions:
97  * 1. The from_addr_rev_path is used to include the reverse source
98  * route per RFC 821 reverse-path option.
99  * 2. The email contains the memo header. The mail data includes
100  * the memo header items such at DATE, Subject, TO, CC and From.
101  *------------------------------------------------------------------*/
123 int SendMailEx(IPADDR smtp_server,
124  PCSTR userid,
125  PCSTR from_addr_rev_path,
126  PCSTR from_addr_memo_hdr,
127  PCSTR to_addr,
128  PCSTR subject,
129  PCSTR textbody);
130 
131 /*-------------------------------------------------------------------
132  * Send an email as if the NetBurner device was a SMTP server, rather
133  * than the standard way of sending an email through an external
134  * SMTP server through a user account.
135  * ------------------------------------------------------------------*/
136 int SendMailAsServer(PCSTR from_addr, PCSTR to_addr, PCSTR subject, PCSTR textbody);
137 
138 extern uint16_t SMTP_PORT;
139 extern uint16_t SMTP_AUTH_PORT;
140 extern uint16_t RFC931_PORT;
141 extern uint16_t LOCAL_MAIL_PORT;
142 
143 /*-------------------------------------------------------------------
144  * The following functions, variables and definitions are used for
145  * error reporting of the mail system.
146  * -----------------------------------------------------------------*/
147 
148 // Returns 0 or error code
157 int IsMailError();
158 
171 void PrintNBError(int fd = 0);
172 
186 void PrintServerLog(int fd = 0);
187 
188 // Returns 0 or error code
189 extern int NB_Mail_Error_Code;
190 
191 // Last error string reported by NetBurner mail library. This is usually
192 // displayed on the debug serial port.
193 extern char NB_Mail_Error_String[];
194 
195 // Last error string received from mail server
196 extern char Server_Mail_Log_String[];
197 
201 extern enum CONTENT_TYPE_ENUM {
206  // Add additional types above CONTENT_TYPE_END
208 } CONTENT_TYPE;
210 
247 int SendMailAuthStartMIME(IPADDR smtp_server, PCSTR userid, PCSTR pass, PCSTR from_addr, PCSTR to_addr, PCSTR subject, int &fd);
248 
266 int SendMailAuthAddMIME(int fd, int ContentType, const char *pContent, const char *FileName);
267 
281 int SendMailAuthEndMIME(int fd, PCSTR userid);
282 
283 void MIME_SendMultipartHeader(int fd);
284 
285 #endif
286 
287 #ifdef _NB_SSL_MAILTO
288 /*-------------------------------------------------------------------
289  * Function to look for matching server return codes
290  * ----------------------------------------------------------------*/
291 int SMPMatch(int fd, int fd931, PCSTR userid, PCSTR match, uint32_t timeout);
292 int writeb64string(int fd, const char *cp);
293 void SaveToMailLog(const char *buffer, int rv);
294 extern uint16_t Server_String_Count;
295 #endif
Additional content types can be added above this line.
Definition: mailto.h:207
int SendMailAuthAddMIME(int fd, int ContentType, const char *pContent, const char *FileName)
Add a MIME part or attachment to an open MIME Session.
Definition: mailto.cpp:888
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition: ipv6_addr.h:28
int SendMailAuth(IPADDR smtp_server, PCSTR userid, PCSTR pass, PCSTR from_addr, PCSTR to_addr, PCSTR subject, PCSTR textbody)
Send an email message with plain text authentication. The function will open a TCP connection to the ...
Definition: mailto.cpp:397
Plain text.
Definition: mailto.h:202
void PrintServerLog(int fd=0)
Prints the server log of the last send mail transaction.
Definition: mailto.cpp:1027
HTML.
Definition: mailto.h:205
int SendMailEx(IPADDR smtp_server, PCSTR userid, PCSTR from_addr_rev_path, PCSTR from_addr_memo_hdr, PCSTR to_addr, PCSTR subject, PCSTR textbody)
Send an email message function, extended version.
Definition: mailto.cpp:175
int SendMail(IPADDR smtp_server, PCSTR userid, PCSTR from_addr, PCSTR to_addr, PCSTR subject, PCSTR textbody)
Send an email message. The function will open a TCP connection to the specified SMTP server...
Definition: mailto.cpp:167
void PrintNBError(int fd=0)
If an error occurred, prints the error information received from the SMTP server. ...
Definition: mailto.cpp:1042
Binary attachment.
Definition: mailto.h:204
Plain text attachment.
Definition: mailto.h:203
CONTENT_TYPE_ENUM
Definition: mailto.h:201
int SendMailAuthEndMIME(int fd, PCSTR userid)
Send a MIME email message and close the SMTP session.
Definition: mailto.cpp:956
int SendMailAuthStartMIME(IPADDR smtp_server, PCSTR userid, PCSTR pass, PCSTR from_addr, PCSTR to_addr, PCSTR subject, int &fd)
Start a Multi-purpose Internet Mail Extension (MIME)session.
Definition: mailto.cpp:646
int IsMailError()
Returns the error status of the last send mail transaction.
Definition: mailto.cpp:1019