sending mail from php when link in message body

时间:2016-06-18 20:15:23

标签: php email

i have a php script

<?php
$to = 'somebody@somedomain.com';
$subject = 'Test mail';
$message = 'mysitedomain.com';
$from = 'support@mysitedomain.com';
$headers = 'From:' . $from;
mail($to,$subject,$message,$headers);
echo 'Mail Sent.';
?>

When i run this code mail not send. If i change message to mysitedomaincom (without dot before com) the mail send succesfull.

Anybody have a solution for this?

1 个答案:

答案 0 :(得分:0)

此代码告诉邮件程序和收件人该电子邮件包含需要解释的格式良好的HTML

如果您希望可以更改$ message的内容,现在使用此代码可以发送HTML内容邮件。

<?PHP
    $to = 'somebody@somedomain.com';

    $subject = 'Test mail';

    $headers =  "From: Support <support@mysitedomain.com>" . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    $message = '<html><body>';
    $message .= '<h1>mysitedomain.com</h1>';
    $message .= '</body></html>';

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