Pee*_*n87 7 email wordpress wp-mail
我使用 wp_mail 从我的 WordPress 主题发送通知。如何将回复地址添加到以下 wp_mail 脚本中:
$recipient = "recipient@example.com";
$headers = array('Content-Type: text/html; charset=UTF-8','From: MyWebsite <'mywebsite@example.com'>');
$message = 'Here is the sent message';
wp_mail( $recipient, 'Here comes the Subject', $message, $headers );
Run Code Online (Sandbox Code Playgroud)
您可以在数组内设置回复地址$headers。它需要在 <> 内包含电子邮件地址,我建议使用名称以确保一切正常。
$headers[] = 'Reply-To: Firstname Lastname <your@mail.com>';
我为您的电子邮件添加了主题。所以你的代码看起来像:
$recipient = "recipient@example.com";
$subject = "Your subject";
$message = "Here is the sent message";
$headers = array(
'Content-Type: text/html; charset=UTF-8',
'From: MyWebsite <mywebsite@example.com>',
'Reply-To: Firstname Lastname <your@mail.com>'
);
wp_mail( $recipient, $subject, $message, $headers );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5570 次 |
| 最近记录: |