Jump to content

phpmailer smtp error


exhaler

Recommended Posts

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.  :shrug::confused:

The above script is working if i run it directly on the mailing server instead of the yahoo one.

 

Thanks for the help

Link to comment
https://forums.phpfreaks.com/topic/251195-phpmailer-smtp-error/
Share on other sites

Well, are you literally trying to make a socket connection to mail.domainname.info[/]? I'm most certain that isn't the address that you would want to use (because it doesn't exist). You need to connect to your actual mail server, and pass your actual login credentials.'

 

Is it possible for you to use the built-in mail() construct? That would be easier if you're just starting out with email in PHP.  Making SMTP connections can be tricky if your mail server has special requirements.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.