Các chức năng thư trong PHP
Giới thiệu thư PHP
Hàm mail () cho phép bạn gửi email trực tiếp từ một tập lệnh.
Yêu cầu
Để các chức năng thư khả dụng, PHP yêu cầu một hệ thống email được cài đặt và hoạt động. Chương trình sẽ được sử dụng được xác định bởi cài đặt cấu hình trong tệp php.ini.
Cài đặt
Các hàm mail là một phần của lõi PHP. Không cần cài đặt để sử dụng các chức năng này.
Cấu hình thời gian chạy
Hoạt động của các chức năng thư bị ảnh hưởng bởi cài đặt trong php.ini:
Name | Default | Description | Changeable |
---|---|---|---|
mail.add_x_header | "0" | Add X-PHP-Originating-Script that will include UID of the script followed by the filename. For PHP 5.3.0 and above | PHP_INI_PERDIR |
mail.log | NULL | The path to a log file that will log all mail() calls. Log include full path of script, line number, To address and headers. For PHP 5.3.0 and above | PHP_INI_PERDIR |
SMTP | "localhost" | Windows only: The DNS name or IP address of the SMTP server | PHP_INI_ALL |
smtp_port | "25" | Windows only: The SMTP port number. For PHP 4.3.0 and above | PHP_INI_ALL |
sendmail_from | NULL | Windows only: Specifies the "from" address to be used when sending mail from mail() | PHP_INI_ALL |
sendmail_path | "/usr/sbin/sendmail -t -i" | Specifies where the sendmail program can be found. This directive works also under Windows. If set, SMTP, smtp_port and sendmail_from are ignored | PHP_INI_SYSTEM |
Các chức năng thư trong PHP
Function | Description |
---|---|
ezmlm_hash() | Calculates the hash value needed by EZMLM |
mail() | Allows you to send emails directly from a script |