Osman Khalid
Osman Khalid

Reputation: 798

phpmailer No Relay Access Allowed Error

My website is hosted on godaddy, and I just figured out that my website is no more sending emails through phpmailer since last few months. I uploaded the latest version of phpmailer but still no success. The online web mail of my website runs fine. If I use php's "mail" function, it does send emails to gmail, but not to yahoo accounts.

I tried all the three ports 25, 465, and 587, but no luck

I am getting the following error from phpmailer:

SERVER -> CLIENT: 554 p3plsmtpa07-10.prod.phx3.secureserver.net ESMTP No Relay Access Allowed From 50.63.196.51
CLIENT -> SERVER: EHLO lostandfound.pakproject.com
SERVER -> CLIENT: 
SMTP ERROR: EHLO command failed: 
SMTP NOTICE: EOF caught while checking if connected
SMTP Error: Could not authenticate.
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Following is my code that I am trying to test. (User name, passwords, emails are changed...)

<?php

date_default_timezone_set('Etc/UTC');    
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';    
$mail->Host = "smtpout.... my_server";    
$mail->Port = 25;    
$mail->SMTPAuth = true;    
$mail->Username = "here_i_used_my_website_email"; 

$mail->Password = "here_password";    
$mail->setFrom('website_email', 'From name');   
$mail->addReplyTo('website_email', 'From name');    
$mail->addAddress('another_email', 'name_used_here'); 

$mail->Subject = 'About the task';    
$mail->Body = 'This is email body';    
$mail->AltBody = 'This is a plain-text message body';

if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
?>

Upvotes: 0

Views: 825

Answers (2)

Osman Khalid
Osman Khalid

Reputation: 798

I was able to resolve my issue with the following code/settings of phpmailer

<?php


$recipient = "[email protected]"
$subject = "Subject here";
$emailBody = "This is body";


// PHP MAILER CODE STARTS FROM HERE //
require '../phpmailermaster/PHPMailerAutoload.php';
$mail = new PHPMailer;

//$mail->SMTPDebug = 3;    // Enable verbose debug output

$mail->isSMTP();       // Set mailer to use SMTP
$mail->Host = 'smtpout.secureserver.net'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '3344123';  // SMTP password

//$mail->SMTPSecure = 'ssl';    // Enable TLS encryption, `ssl` also accepted
//$mail->Port = 465;

$mail->Port = 80;   // TCP port to connect to [THIS PORT ALLOWING EMAILS]
$mail->setFrom('[email protected]', 'hello');

//$mail->addAddress('[email protected]', 'Joe User');     // Add a recipient

$mail->addAddress($recipient);                 // Name is optional

//$mail->addReplyTo('[email protected]', 'Information');

//$mail->addBCC('[email protected]');
//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
//$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = $subject;
$mail->Body    = $emailBody;
$mail->AltBody = $emailBody;

if(!$mail->send()) 
{
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} 
else 
{
    echo 'Message has been sent';       
}

// PHP MAILER CODE ENDS HERE ==


?>

Upvotes: 0

fdo pineda
fdo pineda

Reputation: 11

    $mail->SMTPSecure = false; 
    $mail->SMTPAuth = false;

It worked for me. Keep in mind https://co.godaddy.com/help/mail-server-addresses-and-ports-for-business-email-24071**

Upvotes: 1

Related Questions