PHP邮件程序没有收到电子邮件

时间:2014-11-23 06:01:45

标签: php html sql

在我的网站上,我没有收到表单提交的电子邮件。我尝试了很多东西,但无法弄清楚问题。标头是否必要?代码如下。

if (@$_POST['submitted']) {

if ($error_msg) {
    echo "<div id='textcontainer'>\n";
    foreach ($error_msg as $err) {
    echo "<li><strong>".$err."</strong></li>\n";
    }
    echo "</ul>\n";
}

    else {
    $fn_call = '<strong>First Name:</strong>';
    $fn_call2 = strip_tags($fn_call);

    $ln_call = '<strong>Last Name:</strong>';
    $ln_call2 = strip_tags($ln_call);

    $e_call = '<strong>Email:</strong>';
    $e_call2 = strip_tags($e_call);

    $p_call = '<strong>Phone:</strong>';
    $p_call2 = strip_tags($p_call);

    $pd_call = '<strong>Problem Description:</strong>';
    $pd_call2 = strip_tags($pd_call);

    $dt_call = '<strong>Date Submitted:</strong>';
    $ip_call = '<strong>IP Address:</strong>';

date_default_timezone_set('America/New_York');
$EST_Time = date('m/d/y h:i:s a', time());
$ipaddress = $_SERVER['REMOTE_ADDR'];

$destination_email="myemail@gmail.com";
$email_subject="Customer Form Submission";       
$email_body = "$fn_call2 $fname\n\n $ln_call2 $lname\n\n $e_call2 $email\n\n $p_call2 $phone\n\n $pd_call2 $problem_desc $dt_call $EST_Time\n\n $ip_call $ipaddress\n\n";

mail ($destination_email, $email_subject, $email_body);

我一直在尝试一些事情,目前形式的邮件代码仍无效。见下文。

<?php
    if (!empty($_POST)){
if ($error_msg) {
    echo "<div id='textcontainer'>\n";
    foreach ($error_msg as $err) {
    echo "<li><strong>".$err."</strong></li>\n";
    }
    echo "</ul>\n";
}

    else {  
date_default_timezone_set('America/New_York');
$EST_Time = date('m/d/y h:i:s a', time());
$ipaddress = $_SERVER['REMOTE_ADDR'];

$destination_email="email@gmail.com";
$email_subject="Customer Form Submission";       
$email_body = "First Name: " + $fname + "\n\n" + "Last Name: " + $lname + "\n\n" +  "Email: " + $email + "\n\n" + "Phone: " + $phone + "\n\n" + "Problem Description:" + $problem_desc + "IP Address: " + $ipaddress + "\n\n" + "Date Submitted: " + $EST_Time;

mail ($destination_email, $email_subject, $email_body);

更新

出于测试目的,我注释掉了上面的代码,并将其添加到位,这是应该工作的简单正确的代码。但事实并非如此。我应该再向godaddy抱怨吗?这有什么问题?

$to = "myemail@gmail.com"; 
$subject = "Email from php";
$body = "Hi this is a test";

mail($to, $subject, $body);

0 个答案:

没有答案