dongzhang1864 2014-05-20 08:30
浏览 41
已采纳

使用php发送mail()但发件人名称始终为Apache

I really need a quick fix and haven't found any solution to my problem. I want to send email to the user but the sender name always shows Apache.

Here is my coding.

<?php

$password = rand(1000,9999);

$firstname = "syamsul";
$surname = "rizal";
$email = "example@yahoo.com";
$max_id = 3;


//Generate Email

$to = $email;
$subject = "Welcome to ShopOnline!";
$message = "Dear " .$firstname. ", welcome to use ShopOnline! Your Customer id is " .$max_id. " and the password is ".$password.".";
$headers = "From registration@shoponline.com.au" ;

// send mail
    mail($to,$subject,$message,$headers, "-r 4914031@yahoo.com");
    echo "Thank you for sending us feedback";
    ?>

And why i can't send this email to gmail account but works to non-gmail account? Thanks in advance!

  • 写回答

3条回答 默认 最新

  • duang8642 2014-05-20 08:33
    关注

    set your header like

    $headers = "From: registration@shoponline.com.au" . "
    " .
               "Reply-To: registration@shoponline.com.au" . "
    " .
               "X-Mailer: PHP/" . phpversion();
    

    UPDATE 2 :

    with sender name

    $headers = "From: Sender_Name<registration@shoponline.com.au>" . "
    " .
               "Reply-To: registration@shoponline.com.au" . "
    " .
               "X-Mailer: PHP/" . phpversion();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题