duanseci1039 2013-03-06 05:12
浏览 53
已采纳

如何使用php从xampp发送匿名电子邮件

I am trying to set my localhost to send email from xampp using PHP. how to do it so that I will be able to send email with any name to a valid email id.for example I should be able to send email from address mymail@rajkumar.com.

  • 写回答

1条回答 默认 最新

  • dorkahemp972157683 2013-03-06 05:24
    关注

    You would be using PHP's mail function: http://php.net/manual/en/function.mail.php

    The documentation says:

    bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
    

    The from address on an email is included in the $additional_headers. Look at this example below (also from PHP.net):

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

    EDIT (elaborating spam notice):

    Anyone can use mail headers to send an email from any address. For example, I can send an email to you and make it look like the sender is urgent@ups.com. This email could contain some malicious files or a link to a phishing site. When you use your localhost XAMPP server to send mail from mymail@rajkumar.com many email clients will try to verify that the mail indeed originated from rajkumar.com. Since it originated from whatever the IP address of your localhost server is and not the domain you claimed to be sending from, it most likely will be marked as spam.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程