smtp.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef HEADER_CURL_SMTP_H
  2. #define HEADER_CURL_SMTP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2009 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. ***************************************************************************/
  24. #include "pingpong.h"
  25. #include "curl_sasl.h"
  26. /****************************************************************************
  27. * SMTP unique setup
  28. ***************************************************************************/
  29. typedef enum {
  30. SMTP_STOP, /* do nothing state, stops the state machine */
  31. SMTP_SERVERGREET, /* waiting for the initial greeting immediately after
  32. a connect */
  33. SMTP_EHLO,
  34. SMTP_HELO,
  35. SMTP_STARTTLS,
  36. SMTP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
  37. (multi mode only) */
  38. SMTP_AUTH,
  39. SMTP_COMMAND, /* VRFY, EXPN, NOOP, RSET and HELP */
  40. SMTP_MAIL, /* MAIL FROM */
  41. SMTP_RCPT, /* RCPT TO */
  42. SMTP_DATA,
  43. SMTP_POSTDATA,
  44. SMTP_QUIT,
  45. SMTP_LAST /* never used */
  46. } smtpstate;
  47. /* This SMTP struct is used in the Curl_easy. All SMTP data that is
  48. connection-oriented must be in smtp_conn to properly deal with the fact that
  49. perhaps the Curl_easy is changed between the times the connection is
  50. used. */
  51. struct SMTP {
  52. curl_pp_transfer transfer;
  53. char *custom; /* Custom Request */
  54. struct curl_slist *rcpt; /* Recipient list */
  55. size_t eob; /* Number of bytes of the EOB (End Of Body) that
  56. have been received so far */
  57. bool trailing_crlf; /* Specifies if the tailing CRLF is present */
  58. };
  59. /* smtp_conn is used for struct connection-oriented data in the connectdata
  60. struct */
  61. struct smtp_conn {
  62. struct pingpong pp;
  63. smtpstate state; /* Always use smtp.c:state() to change state! */
  64. bool ssldone; /* Is connect() over SSL done? */
  65. char *domain; /* Client address/name to send in the EHLO */
  66. struct SASL sasl; /* SASL-related storage */
  67. bool tls_supported; /* StartTLS capability supported by server */
  68. bool size_supported; /* If server supports SIZE extension according to
  69. RFC 1870 */
  70. bool auth_supported; /* AUTH capability supported by server */
  71. };
  72. extern const struct Curl_handler Curl_handler_smtp;
  73. extern const struct Curl_handler Curl_handler_smtps;
  74. /* this is the 5-bytes End-Of-Body marker for SMTP */
  75. #define SMTP_EOB "\x0d\x0a\x2e\x0d\x0a"
  76. #define SMTP_EOB_LEN 5
  77. #define SMTP_EOB_FIND_LEN 3
  78. /* if found in data, replace it with this string instead */
  79. #define SMTP_EOB_REPL "\x0d\x0a\x2e\x2e"
  80. #define SMTP_EOB_REPL_LEN 4
  81. CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread);
  82. #endif /* HEADER_CURL_SMTP_H */