Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHPMailer error, can't send

Posted on 2013-06-25
9
Medium Priority
?
726 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The viewer will learn how to count occurrences of each item in an array.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

650 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