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
Solved

PHPMailer error, can't send

Posted on 2013-06-25
9
711 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
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 28

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 28

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

 
LVL 4

Expert Comment

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

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 28

Accepted Solution

by:
Jan Springer earned 250 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 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 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 28

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Explore the encryption capabilities built into Google Apps and how these features can help you meet privacy policy and regulatory compliance, but are not a full solution. Understand and compare the most popular email encryption services for Google A…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

792 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