从PHP邮件功能发送两封电子邮件

时间:2016-05-06 11:34:26

标签: php email

我尝试使用PHP邮件功能发送两封电子邮件,第一封正在运行但无法发送第二封邮件这是我的代码

<?php
error_reporting(0);
session_start();

if($_REQUEST['contactButton']!="") {
   if( $_SESSION['security_code'] == $_REQUEST['security_code'] && $_SESSION['security_code']!= "" ) {

// Declair Veriables

$sender         = "admin@ranglerz.com";
$subject        = "Ranglerz Quote Confirmation";
$sendername     = "Ranglerz | Web Development Company";
$receiver       = $_POST['customerEmail'];

$sender2        = $_POST['customerEmail'];
$subject2       = "Ranglerz | Quote Request";
$sendername2    = $_POST['customerName'];
$receiver2      = "kashiflatif90@gmail.com";

$name           = $_POST['customerName'];
$website        = $_POST['customerURL'];
$number         = $_POST['customerPhone'];
$services       = $_POST['customerInterest'];
$message        = $_POST['customerMessage'];

// Prepare Email Body Text

$EmailBody  = "<table cellpadding='0' cellspacing='0' width='800'>";
$EmailBody  = $EmailBody . "<tr height='100'>";
$EmailBody  = $EmailBody . "<td bgcolor='#F15D27' align='center'>";
$EmailBody  = $EmailBody . "<h3 style='color:#FFF; font-family:Verdana;'>Welcome to Ranglerz Digital Marketing</h3>";
$EmailBody  = $EmailBody . "</td>";
$EmailBody  = $EmailBody . "</tr>";
$EmailBody  = $EmailBody . "<tr>";
$EmailBody  = $EmailBody . "<td bgcolor='#FAFAFA' style='padding:15px;'>";
$EmailBody  = $EmailBody . "<h4 style='font-family:Verdana; font-size:13px;'>Dear ".$name."</h4>";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px;'>Thank you for contacting us and showing your interest to work with us – one of our representatives will be in contact with you in the next 24-48 hours.! We appreciate that you've taken the time to write us.</p>";
$EmailBody  = $EmailBody . "<br/>";
$EmailBody  = $EmailBody . "<img src='http://www.ranglerz.com/images/logo.png' />";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px;'>+92 (423) 786 2115, +92 (300) 452 1378</p>";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px;'><a href='' target='_blank'>122-B, Sector C Bahria Town Lahore Pakistan</a></p>";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px;'><a href='http://www.ranglerz.com' target='_blank'>www.ranglerz.com</a></p>";
$EmailBody  = $EmailBody . "<br/>";
$EmailBody  = $EmailBody . "<a href='' target='_blank' style='margin-right:5px;'><img src='https://www.facebookbrand.com/img/assets/asset.f.logo.lg.png' width='32' height='32' /></a>";
$EmailBody  = $EmailBody . "<a href='' target='_blank' style='margin-right:5px;'><img src='https://pmcdeadline2.files.wordpress.com/2014/06/twitter-logo.png?w=970' width='32' height='32' /></a>";
$EmailBody  = $EmailBody . "<a href='' target='_blank' style='margin-right:5px;'><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Google_plus.svg/1047px-Google_plus.svg.png' width='32' height='32' /></a>";
$EmailBody  = $EmailBody . "<a href='' target='_blank' style='margin-right:5px;'><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/c/ca/LinkedIn_logo_initials.png/768px-LinkedIn_logo_initials.png' width='32' height='32' /></a>";
$EmailBody  = $EmailBody . "<a href='' target='_blank' style='margin-right:5px;'><img src='http://vignette1.wikia.nocookie.net/eddsworld/images/9/9c/YouTube_logo.png/revision/latest?cb=20130614191901' width='32' height='32' /></a>";
$EmailBody  = $EmailBody . "</td>";
$EmailBody  = $EmailBody . "</tr>";
$EmailBody  = $EmailBody . "<tr height='50'>";
$EmailBody  = $EmailBody . "<td bgcolor='#414143' align='center'>";
$EmailBody  = $EmailBody . "<h2 style='color:#FFF; font-size:12px; font-family:Verdana; font-weight:normal;'>&copy;2012 - 2016 | <a href='' style='color:#FFF; font-size:12px; font-family:Verdana; font-weight:normal;' target='_blank'>Ranglerz Digital Marketing</a> - All Rights Reserved.</h2>";
$EmailBody  = $EmailBody . "</td>";
$EmailBody  = $EmailBody . "</tr>";
$EmailBody  = $EmailBody . "</table>";


// Prepare Email2 Body Text

$EmailBody2 = "<table cellpadding='0' cellspacing='0' width='800'>";
$EmailBody2 = $EmailBody2 . "<tr height='100'>";
$EmailBody2 = $EmailBody2 . "<td bgcolor='#F15D27' align='center'>";
$EmailBody2 = $EmailBody2 . "<h3 style='color:#FFF; font-family:Verdana;'>Welcome to Ranglerz Digital Marketing</h3>";
$EmailBody2 = $EmailBody2 . "</td>";
$EmailBody2 = $EmailBody2 . "</tr>";
$EmailBody2 = $EmailBody2 . "<tr>";
$EmailBody2 = $EmailBody2 . "<td bgcolor='#FAFAFA' style='padding:15px;'>";
$EmailBody2 = $EmailBody2 . "<h4 style='font-family:Verdana; font-size:13px;'>Dear Admin</h4>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'>please assist the following query ASAP.</p>";
$EmailBody2 = $EmailBody2 . "<br />";
$EmailBody2 = $EmailBody2 . "<h4 style='font-family:Verdana; font-size:13px;'><u>Query Details:</u></h4>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Name: </strong>".$name."</p>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Email: </strong><a href='mailto:".$receiver."' target='_blank'>".$receiver."</a></p>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Website: </strong><a href='".$website."' target='_blank'>".$website."</a></p>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Contact No: </strong>".$number."</p>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Interested Service: </strong>".$services."</p>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Message: </strong><br />".$message."</p>";
$EmailBody2 = $EmailBody2 . "</td>";
$EmailBody2 = $EmailBody2 . "</tr>";    
$EmailBody2 = $EmailBody2 . "<tr height='50'>";
$EmailBody2 = $EmailBody2 . "<td bgcolor='#414143' align='center'>";
$EmailBody2 = $EmailBody2 . "<h2 style='color:#FFF; font-size:12px; font-family:Verdana; font-weight:normal;'>&copy;2012 - 2016 | <a href='http://www.ranglerz.com' style='color:#FFF; font-size:12px; font-family:Verdana; font-weight:normal;' target='_blank'>Ranglerz Digital Marketing</a> - All Rights Reserved.</h2>";
$EmailBody2 = $EmailBody2 . "</td>";
$EmailBody2 = $EmailBody2 . "</tr>";
$EmailBody2 = $EmailBody2 . "</table>";

// Send Email 

$success = "MIME-Version: 1.0 \r\n"; 
$success.= "Content-type: text/html;charset=utf-8 \r\n"; 
$success.= "X-Priority: 3\r\n"; 
$success.= "X-Mailer: smail-PHP ".phpversion()."\r\n";
$success = mail($receiver, $subject, $EmailBody, "From: $sendername<$sender>\nReply-To: $sender\nContent-Type: text/html");
$success = mail($receiver2, $subject2, $EmailBody2, "From: $sendername2<$sender2>\nReply-To: $sender2\nContent-Type: text/html");

// Redirect to Page 

    if ($success) {
        $url            = parse_url($_SERVER['HTTP_REFERER']);
        $trimmedHeader  = $url['scheme'] . '://' . $url['host'] . $url['path'];
        header("location:".$trimmedHeader."?REQUEST=SENT");
    } else {
        $url            = parse_url($_SERVER['HTTP_REFERER']);
        $trimmedHeader  = $url['scheme'] . '://' . $url['host'] . $url['path'];
        header("location:".$trimmedHeader."?SENDING=FAILED");
    }
} else {
    $url                = parse_url($_SERVER['HTTP_REFERER']);
    $trimmedHeader      = $url['scheme'] . '://' . $url['host'] . $url['path'];
    header("location:".$trimmedHeader."?CAPTCHA=NOT-MATCH");
    }
}
?>

错误我得到的是&#34;发送失败&#34;每次,电子邮件成功接收到第一个接收器但没有接收到第二个接收器。

0 个答案:

没有答案