xref: /PHP-7.4/ext/standard/php_mail.h (revision 0cf7de1c)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca>                        |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifndef PHP_MAIL_H
20 #define PHP_MAIL_H
21 
22 PHP_FUNCTION(mail);
23 PHP_FUNCTION(ezmlm_hash);
24 
25 PHP_MINFO_FUNCTION(mail);
26 
27 PHPAPI zend_string *php_mail_build_headers(zval *headers);
28 PHPAPI extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd);
29 
30 #define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \
31 do { \
32 	if (Z_TYPE_P(val) == IS_STRING) { \
33 		php_mail_build_headers_elem(&s, key, val); \
34 	} else if (Z_TYPE_P(val) == IS_ARRAY) { \
35 		if (!strncasecmp(target, ZSTR_VAL(key), ZSTR_LEN(key))) { \
36 			php_error_docref(NULL, E_WARNING, "'%s' header must be at most one header. Array is passed for '%s'", target, target); \
37 			continue; \
38 		} \
39 		php_mail_build_headers_elems(&s, key, val); \
40 	} else { \
41 		php_error_docref(NULL, E_WARNING, "Extra header element '%s' cannot be other than string or array.", ZSTR_VAL(key)); \
42 	} \
43 } while(0)
44 
45 
46 #define PHP_MAIL_BUILD_HEADER_DEFAULT(s, key, val) \
47 do { \
48 	if (Z_TYPE_P(val) == IS_STRING) { \
49 		php_mail_build_headers_elem(&s, key, val); \
50 	} else if (Z_TYPE_P(val) == IS_ARRAY) { \
51 		php_mail_build_headers_elems(&s, key, val); \
52 	} else { \
53 		php_error_docref(NULL, E_WARNING, "Extra header element '%s' cannot be other than string or array.", ZSTR_VAL(key)); \
54 	} \
55 } while(0)
56 
57 
58 #endif /* PHP_MAIL_H */
59