Hello all,
i currently have a yahoo hosting and since they have a limit of outgoing emails, i want to use smtp to send emails from another server.
Below is the code i'm using (phpmailer for PHP 4):
<?php
include_once("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Host = "mail.domainname.info";
$mail->Port = 25;
$mail->Username = "
[email protected]";
$mail->Password = "password";
$subject = "domainname";
$body = $mail->getFile("message/header-mail.php");
$body = "<table cellpadding=\"0\" cellspacing=\"0\" width=\"540\">
<tr>
<td align=\"left\" valign=\"top\" style=\"padding-top: 50px;\" >
<span style=\"font-size: 10pt; color: #F58220;\">
text goes here
</span>
</td>
</tr>
</tr>
</table>";
$body .= $mail->getFile("message/footer-mail.php");
$body = eregi_replace("[\]",'',$body);
$mail->From = "
[email protected]";
$mail->FromName = "domainname";
$mail->AddAddress("
[email protected]", "firstname lastname");
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->IsHTML(true);
$mail->MsgHTML($body);
if ($mail->Send()) {
echo "Message sent!";
} else {
echo "Mailer Error: " . $mail->ErrorInfo;
}
?>
the code above gives me this error when i run it: SMTP -> ERROR: Failed to connect to server: No route to host (65) Mailer Error: SMTP Error: Could not connect to SMTP host.
The above script is working if i run it directly on the mailing server instead of the yahoo one.
Thanks for the help