仅在存在时包含$ _POST变量并在PHP中发送邮件

时间:2014-05-28 05:03:06

标签: php

我正在开展一个小项目,我需要在其中发送有关列表中不正确信息的电子邮件。所以,我只需要从表单中发送不正确的数据。一切正常,但没有接收邮件。有什么我做错了。请帮忙......

   if(isset($_POST['report'])){
    $name = $_POST['business'];
    $address = $_POST['address'];
    $phone =$_POST['phone'];
    $email = $_POST['email'];
    $website = $_POST['website'];

    $toemail = "jafar.sain@gmail.com";
    $fromwebsite = "www.biz15.co.in";

    $error_listing = "business name";
    $error_listing_link = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

    $subject = "Biz15 - Report an Error in a Listing from ".$fromwebsite;
    $body = "You have been requested to go through the following errors from the listing - ".$error_listing."\n\n";
    $body .= "Listing Details:\n";
    $body .= "Listing Name - ".$error_listing."\n";
    $body .= "Listing Url - ".$error_listing_link."\n\n";
    $body .= "Error Details:\n";
    if($name){$body .= "Business Name - ".$name."\n";}
    if($address){$body .= "Address - ".$address."\n";}
    if($phone){$body .= "Phone Number - ".$phone."\n";}
    if($email){$body .= "Email - ".$email."\n";}
    if($website){$body .= "Website - ".$website."\n\n";}
    $body .= "---------------------------------------------------------------------------\n\n";
    $headers = "MIME-Version: 1.0\n"."From: ".$toemail."\n"."Content-type: text/plain; charset=iso-8859-1\n";
    if(@mail($toemail,$subject,$body,$headers)){
        echo "<script type='text/javascript'>alert('Success');</script>";
    }
    else{
        echo "<script type='text/javascript'>alert('Failed');</script>";
    }
}

0 个答案:

没有答案