$headers 无法在 centos 上运行
$headers not working on centos
我有一个简单的邮件功能:
$to = 'someone@somedomain.com';
$cc = 'someother@somedomain.com';
$bcc = 'someotherother@somedomain.com';
$sub = 'Some Subject';
$body = $html;
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=iso-8859-1";
$headers[] = "From: Fancy Name <from@email.com>";
$headers[] = "Reply-To: Fancy Name <from@email.com>";
$headers[] = 'CC: '. $cc;
$headers[] = 'BCC: '. $bcc;
mail($to, $sub, $body, implode("\n", $headers));
这适用于 windows 但不适用于 CentOS - 日志 return "Envelope From address apache@host is't allowed"(或类似的东西)。
调查了一下,作为第 5 个参数,您可以从@email.com 传递 -f,这确实有效。但它没有显示为 Fancy Name,它显示了电子邮件地址 - 我怎样才能让 headers 正常工作或将名称传递给 -f 参数?
谢谢
尝试运行这段代码并告诉我
mail ('user@to-email.com', "Testing Mail Server", "This is a test email from CentOS web server", null, "-f user@from-email.com");
找到解决方案:
按照您的意愿执行 headers 并在第 5 个参数中执行 -f email@domain -F "Sender Name" 例如
$to = 'someone@somedomain.com';
$cc = 'someother@somedomain.com';
$bcc = 'someotherother@somedomain.com';
$sub = 'Some Subject';
$body = $html;
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=iso-8859-1";
$headers[] = "From: Fancy Name <from@email.com>";
$headers[] = "Reply-To: Fancy Name <from@email.com>";
$headers[] = 'CC: '. $cc;
$headers[] = 'BCC: '. $bcc;
mail($to, $sub, $body, implode("\n", $headers), '-f from@email.com -F "Fancy Name"');
我有一个简单的邮件功能:
$to = 'someone@somedomain.com';
$cc = 'someother@somedomain.com';
$bcc = 'someotherother@somedomain.com';
$sub = 'Some Subject';
$body = $html;
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=iso-8859-1";
$headers[] = "From: Fancy Name <from@email.com>";
$headers[] = "Reply-To: Fancy Name <from@email.com>";
$headers[] = 'CC: '. $cc;
$headers[] = 'BCC: '. $bcc;
mail($to, $sub, $body, implode("\n", $headers));
这适用于 windows 但不适用于 CentOS - 日志 return "Envelope From address apache@host is't allowed"(或类似的东西)。
调查了一下,作为第 5 个参数,您可以从@email.com 传递 -f,这确实有效。但它没有显示为 Fancy Name,它显示了电子邮件地址 - 我怎样才能让 headers 正常工作或将名称传递给 -f 参数?
谢谢
尝试运行这段代码并告诉我
mail ('user@to-email.com', "Testing Mail Server", "This is a test email from CentOS web server", null, "-f user@from-email.com");
找到解决方案:
按照您的意愿执行 headers 并在第 5 个参数中执行 -f email@domain -F "Sender Name" 例如
$to = 'someone@somedomain.com';
$cc = 'someother@somedomain.com';
$bcc = 'someotherother@somedomain.com';
$sub = 'Some Subject';
$body = $html;
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=iso-8859-1";
$headers[] = "From: Fancy Name <from@email.com>";
$headers[] = "Reply-To: Fancy Name <from@email.com>";
$headers[] = 'CC: '. $cc;
$headers[] = 'BCC: '. $bcc;
mail($to, $sub, $body, implode("\n", $headers), '-f from@email.com -F "Fancy Name"');