Hi all
Is there any way I can get the errors generated by the mail() function. I am trying to send to emails, the one gets sent and the second one doesn't.
The code is below
$subject = "New Order from " .$shopConfig['name'] .' '. $shopConfig['order_prefix'].$_SESSION['orderId'];
$email = $shopConfig['email'];
$message = 'HTML code for
</html>';
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= "From:".$shopConfig['name']." <".$shopConfig['email'].">" . "\r\n";
if(mail($email, $subject, $message, $headers)){
echo 'email sent';
}
else{
echo 'Unable to send email';
}
}
//send email to customer
$subject = 'Thank you for your order from ' .$shopConfig['name'];
$email = $od_email;
echo $email;
$message = '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<title>Thank you for your order from '.$shopConfig['name'].'</title>
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="margin:0; padding:0;">
<center>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" bgcolor="#888" style="font-size: 16px; font-family: \'Segoe UI\', \'Helvetica Neue\', \'Helvetica\', \'Roboto\', Arial, sans-serif; height:100% !important; margin:0; padding:0; width:100% !important; background-color: #888;">
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="600" bgcolor="#1768dd" style="font-family: \'Segoe UI\', \'Helvetica Neue\', \'Helvetica\', \'Roboto\', Arial, sans-serif; background-color: #1768dd;">
<tr>
<td width="600" height="10" bgcolor="#3e94d1" style="background-color: #3e94d1; height: 10px;"></td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="20" cellspacing="0" width="600" bgcolor="#1768dd" style="font-family: \'Segoe UI\', \'Helvetica Neue\', \'Helvetica\', \'Roboto\', Arial, sans-serif; background-color: #1768dd;">
<tr>
<td width="240" align="left">
<img src="'.$shopConfig['url'].'images/logo.png" style="max-width:240px;" />
</td>
<td width="140">
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#1768dd" style="font-family: \'Segoe UI\', \'Helvetica Neue\', \'Helvetica\', \'Roboto\', Arial, sans-serif; background-color: #1768dd;" align="right">
<tr height="40">
<td width="50%" align="right" valign="top">
<a href="http://www.facebook.com/'.$facebook['facebook_name'].'" target="_blank" style="text-decoration: none;"><img src="'.$shopConfig['url'].'images/facebook.png" alt="Facebook" width="28" height="28" border="0" /></a>
</td>
<td width="50%" align="right" valign="top">
<a href="http://www.twitter.com/'.$twitter['twitter_name'].'" target="_blank" style="text-decoration: none;"><img src="'.$shopConfig['url'].'images/twitter.png" alt="Twitter" width="28" height="28" border="0" /></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
</td>
</tr>
<tr>
<td align="center" valign="top">
<!-- // Begin Template Body \\ -->
<table border="0" cellpadding="0" cellspacing="0" width="600" style="font-family: \'Segoe UI\', \'Helvetica Neue\', \'Helvetica\', \'Roboto\', Arial, sans-serif; color: #969696;">
<tr>
<td valign="top" bgcolor="#1768dd" style="background-color:#1768dd;">
<!-- // Begin Content \\ -->
<table border="0" cellpadding="20" cellspacing="0" width="100%" style="font-family: \'Segoe UI\', \'Helvetica Neue\', \'Helvetica\', \'Roboto\', Arial, sans-serif; color: #ffffff;">
<tr>
<td align="left" valign="top">
<!-- // Begin Content Header \\ -->
<h1 style="color: #ffffff; display:block; font-size:34px; font-weight: normal; line-height:100%; margin-top:0; margin-right:0; margin-bottom:20px; margin-left:0; text-align:left;">Thank you for your order</h1>
<!-- // End Content Header \\ -->
<!-- Order Details-->
<table width="100%" color="ffffff" cellspacing="40px">
<tr>
<td width="50%"><b>Delivery Details</b></td>
<td width="50%"><b>Payment Details</b></td>
</tr>
<tr>
<td>
'.$od_shipping_first_name.' '.$od_shipping_last_name.'<br/>
'.$od_shipping_address1.'<br/>
'.$od_shipping_address2.'<br/>
'.$od_shipping_city.'<br/>
'.$od_shipping_state.'<br/>
'.$od_shipping_postal_code.'
</td>
<td>
'.$od_payment_first_name.' '.$od_payment_last_name.'<br/>
'.$od_payment_address1.'<br/>
'.$od_payment_address2.'<br/>
'.$od_payment_city.'<br/>
'.$od_payment_state.'<br/>
'.$od_payment_postal_code.'
</td>
</tr>
</table>
<table width="100%" color="#ffffff">
<tr>
<th>Item</th>
<th>Size</th>
<th>Unit Cost</th>
<th>Quantity</th>
<th>Price</th>
</tr>
'.$items.'
<tr>
<td align="right" colspan="4">Subtotal</td><td>'.$od_sub_total.'</td></tr>
<td align="right" colspan="4">Shipping</td><td>'.$od_shipping_cost.'</td></tr>
<td align="right" colspan="4">Total</td><td>'.$od_total.'</td></tr>
</table>
</td>
</tr>
</table>
<!-- // End Content \\ -->
</td>
</tr>
</table>
<!-- // End Template Body \\ -->
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- // End Template Footer \\ -->
</td>
</tr>
</table>
</center>
</body>
</html>';
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= "From:".$shopConfig['name']." <".$shopConfig['email'].">" . "\r\n";
if(mail($email, $subject, $message, $headers)){
echo 'email sent';
}
else{
echo 'Unable to send email';
}
If I could get the errors displayed on screen as to why it won't send I could try and solve it