smtp.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef __SMTP_H
  2. #define __SMTP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2009 - 2011, 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_AUTHPLAIN,
  38. SMTP_AUTHLOGIN,
  39. SMTP_AUTHPASSWD,
  40. SMTP_AUTHCRAM,
  41. SMTP_AUTH,
  42. SMTP_MAIL, /* MAIL FROM */
  43. SMTP_RCPT, /* RCPT TO */
  44. SMTP_DATA,
  45. SMTP_POSTDATA,
  46. SMTP_QUIT,
  47. SMTP_LAST /* never used */
  48. } smtpstate;
  49. /* smtp_conn is used for struct connection-oriented data in the connectdata
  50. struct */
  51. struct smtp_conn {
  52. struct pingpong pp;
  53. char *domain; /* what to send in the EHLO */
  54. size_t eob; /* number of bytes of the EOB (End Of Body) that has been
  55. received thus far */
  56. unsigned int authmechs; /* Accepted authentication methods. */
  57. smtpstate state; /* always use smtp.c:state() to change state! */
  58. struct curl_slist *rcpt;
  59. bool ssldone; /* is connect() over SSL done? only relevant in multi mode */
  60. };
  61. /* Authentication mechanism flags. */
  62. #define SMTP_AUTH_LOGIN 0x0001
  63. #define SMTP_AUTH_PLAIN 0x0002
  64. #define SMTP_AUTH_CRAM_MD5 0x0004
  65. #define SMTP_AUTH_DIGEST_MD5 0x0008
  66. #define SMTP_AUTH_GSSAPI 0x0010
  67. #define SMTP_AUTH_EXTERNAL 0x0020
  68. extern const struct Curl_handler Curl_handler_smtp;
  69. extern const struct Curl_handler Curl_handler_smtps;
  70. /* this is the 5-bytes End-Of-Body marker for SMTP */
  71. #define SMTP_EOB "\x0d\x0a\x2e\x0d\x0a"
  72. #define SMTP_EOB_LEN 5
  73. /* if found in data, replace it with this string instead */
  74. #define SMTP_EOB_REPL "\x0d\x0a\x2e\x2e"
  75. #define SMTP_EOB_REPL_LEN 4
  76. CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread);
  77. #endif /* __SMTP_H */