设置电子邮件“发件人”的“名称”

时间:2010-09-14 05:57:26

标签: php mysql

如果在满足特定条件的提交上发表评论(subcheck = 1),则下面的代码应发送电子邮件。它运作得相当好。

但是,显示的发件人的“名称”是两个由点分隔的7位数字。我怎么能把发件人的名字变成别的东西,例如no-reply@domain.com?

提前致谢,

约翰

$querye = mysql_query("SELECT subcheck FROM submission WHERE subcheck = '1' AND submissionid = '$submissionid' ");

if (mysql_num_rows($querye) == 1)
{

$email_query = "SELECT email FROM login WHERE username = '$submittor'";
$result = mysql_query($email_query);
if (!$result) {
        trigger_error('Invalid query: ' . mysql_error()." in ".$email_query);
}

if($row = mysql_fetch_assoc($result)) {
        $mailaddress = $row['email'];
        $queryem = mail($mailaddress, "Someone has commented on your submission 
                        $submission.", $comment, "no-reply@domain.com");
}else{
        // no rows found.
}

}
else
{
//your subcheck is not 1 / nothing was found
}

1 个答案:

答案 0 :(得分:3)

只需添加FROM:,您的代码将如下所示:

mail($mailaddress, "Someone has commented on your submission 
                        $submission.", $comment, "FROM: no-reply@domain.com");