我的PHP代码发送空电子邮件

时间:2014-10-22 08:09:34

标签: php email

请,这是我以前从HTML联系页面发送的PHP代码,它可以解决错误,但只收到空邮件!只是我得到的电子邮件的对象,没有别的。

 <?php

$email_address = $_POST["email"];
$tel_num = $_POST["tel"];
$first_name = $_POST["f_name"];
$last_name = $_POST["l_name"];
$text_send = $_POST["email_text"];
$to_com = "myemal@gmail.com" ;
$subject = " New eMail" ;

    mail ($to_com, $subject, $text_send, " From: " . $email_address . $tel_num . $first_name .$last_name );

    echo "Your Massage has been sent" ;

?>

所以,我需要一些帮助吗?

1 个答案:

答案 0 :(得分:2)

请从php.net

查看此示例
<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

标题中的行结尾(\r\n)非常重要

相关问题