xref: /php-src/ext/standard/php_mail.h (revision 04e8e55f)
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 
17 #ifndef PHP_MAIL_H
18 #define PHP_MAIL_H
19 
20 PHP_MINFO_FUNCTION(mail);
21 
22 PHPAPI zend_string *php_mail_build_headers(HashTable *headers);
23 PHPAPI extern int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd);
24 
25 #define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \
26 do { \
27 	if (Z_TYPE_P(val) == IS_STRING) { \
28 		php_mail_build_headers_elem(&s, key, val); \
29 	} else if (Z_TYPE_P(val) == IS_ARRAY) { \
30 		if (zend_string_equals_literal_ci(key, target)) { \
31 			zend_type_error("Header \"%s\" must be of type string, array given", target); \
32 			break; \
33 		} \
34 		php_mail_build_headers_elems(&s, key, val); \
35 	} else { \
36 		zend_type_error("Header \"%s\" must be of type array|string, %s given", ZSTR_VAL(key), zend_zval_value_name(val)); \
37 	} \
38 } while(0)
39 
40 
41 #define PHP_MAIL_BUILD_HEADER_DEFAULT(s, key, val) \
42 do { \
43 	if (Z_TYPE_P(val) == IS_STRING) { \
44 		php_mail_build_headers_elem(&s, key, val); \
45 	} else if (Z_TYPE_P(val) == IS_ARRAY) { \
46 		php_mail_build_headers_elems(&s, key, val); \
47 	} else { \
48 		zend_type_error("Header \"%s\" must be of type array|string, %s given", ZSTR_VAL(key), zend_zval_value_name(val)); \
49 	} \
50 } while(0)
51 
52 typedef enum {
53 	NO_HEADER_ERROR,
54 	CONTAINS_LF_ONLY,
55 	CONTAINS_CR_ONLY,
56 	CONTAINS_CRLF,
57 	CONTAINS_NULL
58 } php_mail_header_value_error_type;
59 
60 #endif /* PHP_MAIL_H */
61