113498266Sopenharmony_ci#ifndef HEADER_CURL_SMTP_H 213498266Sopenharmony_ci#define HEADER_CURL_SMTP_H 313498266Sopenharmony_ci/*************************************************************************** 413498266Sopenharmony_ci * _ _ ____ _ 513498266Sopenharmony_ci * Project ___| | | | _ \| | 613498266Sopenharmony_ci * / __| | | | |_) | | 713498266Sopenharmony_ci * | (__| |_| | _ <| |___ 813498266Sopenharmony_ci * \___|\___/|_| \_\_____| 913498266Sopenharmony_ci * 1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 1113498266Sopenharmony_ci * 1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which 1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms 1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html. 1513498266Sopenharmony_ci * 1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell 1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is 1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file. 1913498266Sopenharmony_ci * 2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 2113498266Sopenharmony_ci * KIND, either express or implied. 2213498266Sopenharmony_ci * 2313498266Sopenharmony_ci * SPDX-License-Identifier: curl 2413498266Sopenharmony_ci * 2513498266Sopenharmony_ci ***************************************************************************/ 2613498266Sopenharmony_ci 2713498266Sopenharmony_ci#include "pingpong.h" 2813498266Sopenharmony_ci#include "curl_sasl.h" 2913498266Sopenharmony_ci 3013498266Sopenharmony_ci/**************************************************************************** 3113498266Sopenharmony_ci * SMTP unique setup 3213498266Sopenharmony_ci ***************************************************************************/ 3313498266Sopenharmony_citypedef enum { 3413498266Sopenharmony_ci SMTP_STOP, /* do nothing state, stops the state machine */ 3513498266Sopenharmony_ci SMTP_SERVERGREET, /* waiting for the initial greeting immediately after 3613498266Sopenharmony_ci a connect */ 3713498266Sopenharmony_ci SMTP_EHLO, 3813498266Sopenharmony_ci SMTP_HELO, 3913498266Sopenharmony_ci SMTP_STARTTLS, 4013498266Sopenharmony_ci SMTP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS 4113498266Sopenharmony_ci (multi mode only) */ 4213498266Sopenharmony_ci SMTP_AUTH, 4313498266Sopenharmony_ci SMTP_COMMAND, /* VRFY, EXPN, NOOP, RSET and HELP */ 4413498266Sopenharmony_ci SMTP_MAIL, /* MAIL FROM */ 4513498266Sopenharmony_ci SMTP_RCPT, /* RCPT TO */ 4613498266Sopenharmony_ci SMTP_DATA, 4713498266Sopenharmony_ci SMTP_POSTDATA, 4813498266Sopenharmony_ci SMTP_QUIT, 4913498266Sopenharmony_ci SMTP_LAST /* never used */ 5013498266Sopenharmony_ci} smtpstate; 5113498266Sopenharmony_ci 5213498266Sopenharmony_ci/* This SMTP struct is used in the Curl_easy. All SMTP data that is 5313498266Sopenharmony_ci connection-oriented must be in smtp_conn to properly deal with the fact that 5413498266Sopenharmony_ci perhaps the Curl_easy is changed between the times the connection is 5513498266Sopenharmony_ci used. */ 5613498266Sopenharmony_cistruct SMTP { 5713498266Sopenharmony_ci curl_pp_transfer transfer; 5813498266Sopenharmony_ci char *custom; /* Custom Request */ 5913498266Sopenharmony_ci struct curl_slist *rcpt; /* Recipient list */ 6013498266Sopenharmony_ci int rcpt_last_error; /* The last error received for RCPT TO command */ 6113498266Sopenharmony_ci size_t eob; /* Number of bytes of the EOB (End Of Body) that 6213498266Sopenharmony_ci have been received so far */ 6313498266Sopenharmony_ci BIT(rcpt_had_ok); /* Whether any of RCPT TO commands (depends on 6413498266Sopenharmony_ci total number of recipients) succeeded so far */ 6513498266Sopenharmony_ci BIT(trailing_crlf); /* Specifies if the trailing CRLF is present */ 6613498266Sopenharmony_ci}; 6713498266Sopenharmony_ci 6813498266Sopenharmony_ci/* smtp_conn is used for struct connection-oriented data in the connectdata 6913498266Sopenharmony_ci struct */ 7013498266Sopenharmony_cistruct smtp_conn { 7113498266Sopenharmony_ci struct pingpong pp; 7213498266Sopenharmony_ci struct SASL sasl; /* SASL-related storage */ 7313498266Sopenharmony_ci smtpstate state; /* Always use smtp.c:state() to change state! */ 7413498266Sopenharmony_ci char *domain; /* Client address/name to send in the EHLO */ 7513498266Sopenharmony_ci BIT(ssldone); /* Is connect() over SSL done? */ 7613498266Sopenharmony_ci BIT(tls_supported); /* StartTLS capability supported by server */ 7713498266Sopenharmony_ci BIT(size_supported); /* If server supports SIZE extension according to 7813498266Sopenharmony_ci RFC 1870 */ 7913498266Sopenharmony_ci BIT(utf8_supported); /* If server supports SMTPUTF8 extension according 8013498266Sopenharmony_ci to RFC 6531 */ 8113498266Sopenharmony_ci BIT(auth_supported); /* AUTH capability supported by server */ 8213498266Sopenharmony_ci}; 8313498266Sopenharmony_ci 8413498266Sopenharmony_ciextern const struct Curl_handler Curl_handler_smtp; 8513498266Sopenharmony_ciextern const struct Curl_handler Curl_handler_smtps; 8613498266Sopenharmony_ci 8713498266Sopenharmony_ci/* this is the 5-bytes End-Of-Body marker for SMTP */ 8813498266Sopenharmony_ci#define SMTP_EOB "\x0d\x0a\x2e\x0d\x0a" 8913498266Sopenharmony_ci#define SMTP_EOB_LEN 5 9013498266Sopenharmony_ci#define SMTP_EOB_FIND_LEN 3 9113498266Sopenharmony_ci 9213498266Sopenharmony_ci/* if found in data, replace it with this string instead */ 9313498266Sopenharmony_ci#define SMTP_EOB_REPL "\x0d\x0a\x2e\x2e" 9413498266Sopenharmony_ci#define SMTP_EOB_REPL_LEN 4 9513498266Sopenharmony_ci 9613498266Sopenharmony_ciCURLcode Curl_smtp_escape_eob(struct Curl_easy *data, 9713498266Sopenharmony_ci const ssize_t nread, 9813498266Sopenharmony_ci const ssize_t offset); 9913498266Sopenharmony_ci 10013498266Sopenharmony_ci#endif /* HEADER_CURL_SMTP_H */ 101