This question already has an answer here:
- php mail function not getting the emails 6 answers
I have a mail function
$to = "fahad@somewhere.com";
$subject = "Voucher Number: ".$voucher;
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Voucher#:</strong> </td><td>" . strip_tags($voucher) . "</td></tr>";
$message .= "<tr><td><strong>Name:</strong> </td><td>" . strip_tags($name) . "</td></tr>";
$message .= "<tr><td><strong>Phone Number:</strong> </td><td>" . strip_tags($product) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($email) . "</td></tr>";
//set content-type
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
// More headers
$headers .= 'From: <livingdeal@overstock-king.com>' . "
";
$headers .= 'cc:'. $email . "
";
mail($to,$subject,$message,$headers);
For some reason I'm not getting any mail sent at all. The service is hosted so i'm not running it from localhost, and even when I write
if (mail(....))
{ echo "success";
}
else { echo "failed"; }
I always get success, so my suspicion is that it is a problem on the server end. If php mail goes from port 25 is there any way to change the port to a different one in the script? or would it be in php.ini.
Also, would I be able to use a different server (that has a different domain) to send the mail without redirecting the use to that other webpage? I guess in other words can I connect to an smtp server through a php script before sending the mail?
</div>