2013-03-06 05:12
浏览 53


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.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试将我的localhost设置为使用PHP从xampp发送电子邮件。 如何做到这一点,以便我能够将任何名称的电子邮件发送到有效的电子邮件ID。例如,我应该能够从地址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):

    $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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题