如何更改PHP电子邮件的发件人姓名?

时间:2014-03-20 08:21:36

标签: php email

我有一个发送电子邮件的脚本,但是发件人名称不是“admin@foo.bar”,我希望它说“Foobar Admin”。我怎么能这样做?

谢谢!

4 个答案:

答案 0 :(得分:0)

你想要这样的东西??

$email_from = $full_name.'<'.$email_from.'>';

答案 1 :(得分:0)

试试这个

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

供参考使用http://www.php.net/manual/en/function.mail.php

答案 2 :(得分:0)

使用此功能;

<?php
$to      = 'to@mail.com';
$subject = 'Your subject';
$message = 'Your message';
$headers = 'From: Foobar Admin<admin@foo.bar>' . "\r\n" .
    'Reply-To: admin@foo.bar' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

答案 3 :(得分:0)

mail("recipient@aol.com","subject","message","From:Foobar Admin<foobar@admin.com>");