exhaler Posted November 15, 2011 Share Posted November 15, 2011 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. The above script is working if i run it directly on the mailing server instead of the yahoo one. Thanks for the help Quote Link to comment Share on other sites More sharing options...
exhaler Posted November 15, 2011 Author Share Posted November 15, 2011 i forget to show error in the php this is what i get: Warning: fsockopen(): unable to connect to mail.domainname.info:25 in /phpmailer/class.smtp.php on line 122 Quote Link to comment Share on other sites More sharing options...
phporcaffeine Posted November 15, 2011 Share Posted November 15, 2011 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. Quote Link to comment Share on other sites More sharing options...
exhaler Posted November 15, 2011 Author Share Posted November 15, 2011 hahaha, mail.domainname.info is just an example, i cannot post the actual domain i'm using. Quote Link to comment Share on other sites More sharing options...
exhaler Posted November 17, 2011 Author Share Posted November 17, 2011 i'm able to send using mail() on my yahoo hosting, however i want to use my other server to send emails without having to worry about the email limit Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.