imap_mail

(PHP 4, PHP 5, PHP 7, PHP 8)

imap_mailSend an email message

说明

imap_mail(
    string $to,
    string $subject,
    string $message,
    ?string $additional_headers = null,
    ?string $cc = null,
    ?string $bcc = null,
    ?string $return_path = null
): bool

This function allows sending of emails with correct handling of Cc and Bcc receivers.

The parameters to, cc and bcc are all strings and are all parsed as » RFC822 address lists.

参数

to

The receiver

subject

The mail subject

message

The mail body, see imap_mail_compose()

additional_headers

As string with additional headers to be set on the mail

cc

bcc

The receivers specified in bcc will get the mail, but are excluded from the headers.

return_path

Use this parameter to specify return path upon mail delivery failure. This is useful when using PHP as a mail client for multiple users.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 additional_headers, cc, bcc, and return_path are now nullable.

参见

添加备注

用户贡献的备注 1 note

up
1
Patanjali
6 years ago
In response to Mathias Rav's comment.

While imap_mail might have this $rpath bug, it is hardly comparable to mail, because mail only uses the default send mail server account, and not a real mailbox, which you can programmatically interrogate and clean up.

Using the imap extension allows proper mail management and operation, like users not getting the cryptic server account name followed by 'on behalf of' the 'From' address that mail sourced emails show on some recipient clients.
To Top