[英]Sending an email with headers via wp_mail
I need to send mail from wordpress powered site. 我需要从Wordpress支持的网站发送邮件。 I am using wp_mail.
我正在使用wp_mail。 I want to add $header to the mail so it would say who send it.
我想在邮件中添加$ header,以便说出是谁发送的。
When i use $headers like that: 当我这样使用$ header时:
$headers = "From: $name <$email>"
$name and $email are propper variables* $ name和$ email是适当的变量*
And then 接着
if (wp_mail( $to, $subject, $message, $headers) ) {
echo 'Thanks!';
} else {
echo 'Error!';
I always get "Error!" 我总是收到“错误!” and no mail.
而且没有邮件。 I've read about 'wp_mail_from' and 'wp_mail_from_name' but I dont know how to use it.
我已经读过有关“ wp_mail_from”和“ wp_mail_from_name”的信息,但我不知道如何使用。
Have you tried using $headers as an array? 您是否尝试过将$ headers作为数组使用? Try this instead of the current $headers line you have:
试试这个,而不是当前的$ headers行:
$headers[] = 'From: $name <$email>' . "\\r\\n";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.