?
Solved

PHPMailer error, can't send

Posted on 2013-06-25
9
Medium Priority
?
722 Views
Last Modified: 2013-07-11
I've recently moved one of my websites to a new service provider and for some reason the forms have stopped working. My new provider is saying it's a problem with the script, but I'm using the same code on 2 other services and am having no such problems.

I'm using PHPMailer, authenticated via SMTP. The error I'm receiving is as follows:

SMTP -> ERROR: Failed to connect to server: Permission denied (13)SMTP Connect() failed. Message could not be sent.

Mailer Error: SMTP Connect() failed.

I've setup a very basic script as below for testing, but it's just not working on the new server, but yet the same script is working fine on another.

Can anyone tell me if it's something in the code or whether it's something my hosting provider needs to activate, I'm perplexed?

<?php
	ini_set('display_errors', 1);
	error_reporting(E_ALL);
	include_once('class.phpmailer.php');
		
	$mail             = new PHPMailer(); // defaults to using php "mail()"
	
	$body             = "<p><strong>Name:</strong> Name</p>";
	$body            .= "<p><strong>Email Address:</strong> Email</p>";
	$body            .= "<p><strong>Telephone:</strong> Tel</p>";
	
	$mail->From       = "sender@email.co.uk";
	$mail->FromName   = "sender";
	
	$mail->Subject    = 'Form';
	$mail->AltBody    = "Use an HTML compatible email viewer!";
	
	$mail->MsgHTML($body);
	
	$mail->AddAddress("email@email.co.uk");
		
	$mail->IsSMTP();
	$mail->SMTPAuth = "true";
	$mail->Username = "postmaster@server.co.uk"; 
	$mail->Password = "password"; 
	$mail->Host 	= "mail.server.co.uk";
	$mail->Port = 587;
	$mail->SMTPDebug = true;
	
	if(!$mail->Send())
	{
	   echo "Message could not be sent. <p>";
	   echo "Mailer Error: " . $mail->ErrorInfo;
	   exit;
	}
?>

Open in new window

0
Comment
Question by:djfenom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 29

Expert Comment

by:Jan Springer
ID: 39276326
Ask your provider why you are getting a permission denied when trying to connect to the SMTP server.  Looks like a mail server configuration issue.
0
 
LVL 4

Expert Comment

by:ScorchD
ID: 39276422
Looks like you need to provide log in credentials for your new server, probably something like
$mail->SMTPAuth = true; $mail->Username = ""; $mail->Password = "";

Open in new window

0
 
LVL 29

Expert Comment

by:Jan Springer
ID: 39276440
The author does have SMTP AUTH configured in the script above.

The provider needs to identify why the authid if failing.
0
Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

 
LVL 4

Expert Comment

by:ScorchD
ID: 39276451
Apologies I missed that, yes its a question for your provider.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39276549
Are you sending thru your new Host or some where else?  If it is somewhere else, does your new host allow outgoing connections thru port 587?
0
 

Author Comment

by:djfenom
ID: 39277290
The SMTP authentication goes to an external provider, so it's nothing to do with the new host. The exact same script works on different servers?
0
 
LVL 29

Accepted Solution

by:
Jan Springer earned 750 total points
ID: 39277921
The error message explicitly indicates that you are being refused when connecting to the server.  Either ports 25/587 are restricted and your new host is not in that list or auth account is not configured or the password configured is incorrect.

Your provider should be able to look at the mail configuration and in the mail logs to determine the problem.
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 750 total points
ID: 39278857
It only goes to an external provider if it is not blocked by the new host.  They are not required to let you connect to another SMTP provider.  Hosting companies often block services when they have had trouble like too much outgoing spam.
0
 
LVL 29

Expert Comment

by:Jan Springer
ID: 39278978
That's usually why SMTP AUTH is implemented -- as another avenue to allow authorized users to send outbound email.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
We aren’t perfect, just like everyone else.  Check out the email errors our community caught and learn the top errors every email marketer should avoid.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question