smtp.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __SMTP_H
  2. #define __SMTP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2009 - 2012, 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 http://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. /****************************************************************************
  26. * SMTP unique setup
  27. ***************************************************************************/
  28. typedef enum {
  29. SMTP_STOP, /* do nothing state, stops the state machine */
  30. SMTP_SERVERGREET, /* waiting for the initial greeting immediately after
  31. a connect */
  32. SMTP_EHLO,
  33. SMTP_HELO,
  34. SMTP_STARTTLS,
  35. SMTP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
  36. (multi mode only) */
  37. SMTP_AUTH_PLAIN,
  38. SMTP_AUTH_LOGIN,
  39. SMTP_AUTH_PASSWD,
  40. SMTP_AUTH_CRAMMD5,
  41. SMTP_AUTH_DIGESTMD5,
  42. SMTP_AUTH_DIGESTMD5_RESP,
  43. SMTP_AUTH_NTLM,
  44. SMTP_AUTH_NTLM_TYPE2MSG,
  45. SMTP_AUTH,
  46. SMTP_MAIL, /* MAIL FROM */
  47. SMTP_RCPT, /* RCPT TO */
  48. SMTP_DATA,
  49. SMTP_POSTDATA,
  50. SMTP_QUIT,
  51. SMTP_LAST /* never used */
  52. } smtpstate;
  53. /* smtp_conn is used for struct connection-oriented data in the connectdata
  54. struct */
  55. struct smtp_conn {
  56. struct pingpong pp;
  57. char *domain; /* Client address/name to send in the EHLO */
  58. size_t eob; /* Number of bytes of the EOB (End Of Body) that
  59. have been received so far */
  60. unsigned int authmechs; /* Accepted authentication mechanisms */
  61. unsigned int authused; /* Auth mechanism used for the connection */
  62. smtpstate state; /* Always use smtp.c:state() to change state! */
  63. struct curl_slist *rcpt; /* Recipient list */
  64. bool ssldone; /* Is connect() over SSL done? only relevant in
  65. multi mode */
  66. bool size_supported; /* If server supports SIZE extension according to
  67. RFC 1870 */
  68. };
  69. extern const struct Curl_handler Curl_handler_smtp;
  70. extern const struct Curl_handler Curl_handler_smtps;
  71. /* this is the 5-bytes End-Of-Body marker for SMTP */
  72. #define SMTP_EOB "\x0d\x0a\x2e\x0d\x0a"
  73. #define SMTP_EOB_LEN 5
  74. #define SMTP_EOB_FIND_LEN 3
  75. /* if found in data, replace it with this string instead */
  76. #define SMTP_EOB_REPL "\x0d\x0a\x2e\x2e"
  77. #define SMTP_EOB_REPL_LEN 4
  78. CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread);
  79. #endif /* __SMTP_H */