php_mail.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef PHP_MAIL_H
  17. #define PHP_MAIL_H
  18. PHP_MINFO_FUNCTION(mail);
  19. PHPAPI zend_string *php_mail_build_headers(HashTable *headers);
  20. PHPAPI extern int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd);
  21. #define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \
  22. do { \
  23. if (Z_TYPE_P(val) == IS_STRING) { \
  24. php_mail_build_headers_elem(&s, key, val); \
  25. } else if (Z_TYPE_P(val) == IS_ARRAY) { \
  26. if (zend_string_equals_literal_ci(key, target)) { \
  27. zend_type_error("Header \"%s\" must be of type string, array given", target); \
  28. break; \
  29. } \
  30. php_mail_build_headers_elems(&s, key, val); \
  31. } else { \
  32. zend_type_error("Header \"%s\" must be of type array|string, %s given", ZSTR_VAL(key), zend_zval_type_name(val)); \
  33. } \
  34. } while(0)
  35. #define PHP_MAIL_BUILD_HEADER_DEFAULT(s, key, val) \
  36. do { \
  37. if (Z_TYPE_P(val) == IS_STRING) { \
  38. php_mail_build_headers_elem(&s, key, val); \
  39. } else if (Z_TYPE_P(val) == IS_ARRAY) { \
  40. php_mail_build_headers_elems(&s, key, val); \
  41. } else { \
  42. zend_type_error("Header \"%s\" must be of type array|string, %s given", ZSTR_VAL(key), zend_zval_type_name(val)); \
  43. } \
  44. } while(0)
  45. #endif /* PHP_MAIL_H */