xref: /PHP-7.2/ext/standard/php_mail.h (revision 7a7ec01a)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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 /* $Id$ */
20 
21 #ifndef PHP_MAIL_H
22 #define PHP_MAIL_H
23 
24 PHP_FUNCTION(mail);
25 PHP_FUNCTION(ezmlm_hash);
26 
27 PHP_MINFO_FUNCTION(mail);
28 
29 PHPAPI zend_string *php_mail_build_headers(zval *headers);
30 PHPAPI extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd);
31 
32 #define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \
33 do { \
34 	if (Z_TYPE_P(val) == IS_STRING) { \
35 		php_mail_build_headers_elem(&s, key, val); \
36 	} else if (Z_TYPE_P(val) == IS_ARRAY) { \
37 		if (!strncasecmp(target, ZSTR_VAL(key), ZSTR_LEN(key))) { \
38 			php_error_docref(NULL, E_WARNING, "'%s' header must be at most one header. Array is passed for '%s'", target, target); \
39 			continue; \
40 		} \
41 		php_mail_build_headers_elems(&s, key, val); \
42 	} else { \
43 		php_error_docref(NULL, E_WARNING, "Extra header element '%s' cannot be other than string or array.", ZSTR_VAL(key)); \
44 	} \
45 } while(0)
46 
47 
48 #define PHP_MAIL_BUILD_HEADER_DEFAULT(s, key, val) \
49 do { \
50 	if (Z_TYPE_P(val) == IS_STRING) { \
51 		php_mail_build_headers_elem(&s, key, val); \
52 	} else if (Z_TYPE_P(val) == IS_ARRAY) { \
53 		php_mail_build_headers_elems(&s, key, val); \
54 	} else { \
55 		php_error_docref(NULL, E_WARNING, "Extra header element '%s' cannot be other than string or array.", ZSTR_VAL(key)); \
56 	} \
57 } while(0)
58 
59 
60 #endif /* PHP_MAIL_H */
61