00001 #ifndef HEADER_CURL_SMTP_H 00002 #define HEADER_CURL_SMTP_H 00003 /*************************************************************************** 00004 * _ _ ____ _ 00005 * Project ___| | | | _ \| | 00006 * / __| | | | |_) | | 00007 * | (__| |_| | _ <| |___ 00008 * \___|\___/|_| \_\_____| 00009 * 00010 * Copyright (C) 2009 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. 00011 * 00012 * This software is licensed as described in the file COPYING, which 00013 * you should have received as part of this distribution. The terms 00014 * are also available at https://curl.haxx.se/docs/copyright.html. 00015 * 00016 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 00017 * copies of the Software, and permit persons to whom the Software is 00018 * furnished to do so, under the terms of the COPYING file. 00019 * 00020 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 00021 * KIND, either express or implied. 00022 * 00023 ***************************************************************************/ 00024 00025 #include "pingpong.h" 00026 #include "curl_sasl.h" 00027 00028 /**************************************************************************** 00029 * SMTP unique setup 00030 ***************************************************************************/ 00031 typedef enum { 00032 SMTP_STOP, /* do nothing state, stops the state machine */ 00033 SMTP_SERVERGREET, /* waiting for the initial greeting immediately after 00034 a connect */ 00035 SMTP_EHLO, 00036 SMTP_HELO, 00037 SMTP_STARTTLS, 00038 SMTP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS 00039 (multi mode only) */ 00040 SMTP_AUTH, 00041 SMTP_COMMAND, /* VRFY, EXPN, NOOP, RSET and HELP */ 00042 SMTP_MAIL, /* MAIL FROM */ 00043 SMTP_RCPT, /* RCPT TO */ 00044 SMTP_DATA, 00045 SMTP_POSTDATA, 00046 SMTP_QUIT, 00047 SMTP_LAST /* never used */ 00048 } smtpstate; 00049 00050 /* This SMTP struct is used in the Curl_easy. All SMTP data that is 00051 connection-oriented must be in smtp_conn to properly deal with the fact that 00052 perhaps the Curl_easy is changed between the times the connection is 00053 used. */ 00054 struct SMTP { 00055 curl_pp_transfer transfer; 00056 char *custom; /* Custom Request */ 00057 struct curl_slist *rcpt; /* Recipient list */ 00058 size_t eob; /* Number of bytes of the EOB (End Of Body) that 00059 have been received so far */ 00060 bool trailing_crlf; /* Specifies if the tailing CRLF is present */ 00061 }; 00062 00063 /* smtp_conn is used for struct connection-oriented data in the connectdata 00064 struct */ 00065 struct smtp_conn { 00066 struct pingpong pp; 00067 smtpstate state; /* Always use smtp.c:state() to change state! */ 00068 bool ssldone; /* Is connect() over SSL done? */ 00069 char *domain; /* Client address/name to send in the EHLO */ 00070 struct SASL sasl; /* SASL-related storage */ 00071 bool tls_supported; /* StartTLS capability supported by server */ 00072 bool size_supported; /* If server supports SIZE extension according to 00073 RFC 1870 */ 00074 bool auth_supported; /* AUTH capability supported by server */ 00075 }; 00076 00077 extern const struct Curl_handler Curl_handler_smtp; 00078 extern const struct Curl_handler Curl_handler_smtps; 00079 00080 /* this is the 5-bytes End-Of-Body marker for SMTP */ 00081 #define SMTP_EOB "\x0d\x0a\x2e\x0d\x0a" 00082 #define SMTP_EOB_LEN 5 00083 #define SMTP_EOB_FIND_LEN 3 00084 00085 /* if found in data, replace it with this string instead */ 00086 #define SMTP_EOB_REPL "\x0d\x0a\x2e\x2e" 00087 #define SMTP_EOB_REPL_LEN 4 00088 00089 CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread); 00090 00091 #endif /* HEADER_CURL_SMTP_H */