Reputation: 13
How do you make php's mail function send email from a specific separate SMTP server instead of using the local host?
My code:
<?php
$to = "[email protected]";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
mail($to,$subject,$message,$headers);
?>
Background info: I currently have a Linux server running Apache and also acting as a mail server (foo.com) and a separate server (bar.com) running a LAMP stack.
On bar.com I am trying to code a auto mailer for users registering accounts that sends the emails from foo.com.
Upvotes: 1
Views: 194
Reputation: 2853
mail()
does not support smtp. You need to use a mail framework which supports smtp like: http://pear.php.net/package/Mail
See: smtp configuration for php mail
Upvotes: 0