Solved

PHPMailer error, can't send

Posted on 2013-06-25
9
707 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
Comment Utility
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
Comment Utility
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
Comment Utility
The author does have SMTP AUTH configured in the script above.

The provider needs to identify why the authid if failing.
0
 
LVL 4

Expert Comment

by:ScorchD
Comment Utility
Apologies I missed that, yes its a question for your provider.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Comment Utility
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 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
Comment Utility
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
Comment Utility
That's usually why SMTP AUTH is implemented -- as another avenue to allow authorized users to send outbound email.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to set up an account with Mailchimp. This will be demonstrated using a Windows 8 PC. Tools Used are: Mailchimp.com Go to Mailchimp.com : Enter an Email, Username, and Password. Click Create My Acco…
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now