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   = "web@domainname.info";
$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       = "noreply@domainname.com";
$mail->FromName   = "domainname";

$mail->AddAddress("testemail@gmail.com", "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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.