Does anyone know the correct setting for using PHPMailer with AOL. The code below worked with outlook.com but aol.com keeps refusing it. The code is as follows;
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.aol.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxxxxxxxxxxxxxxxxxx#aol.com'; // SMTP username
$mail->Password = 'yyyyyyyyyyyyyyyyyyyyyy'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//Recipients
$mail->setFrom('xxxxxxxxxxxxxxxxxxx#aol.com', 'Barry AOL');
$mail->addAddress('xxxxxxxxxxxxxxxxxxx#gmail.com', 'Barry gmail'); // Add a recipient
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject - sent from AOL.com ';
$mail->Body = 'This is the HTML message body <b>in bold!</b> - sent from AOL.com ';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients - sent from AOL.com ';
$mail->send();
echo 'Message has been sent from AOL.com ';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
I'm getting the following error messages from PHPMailer and aol.com;
2018-04-22 21:44:56 SERVER -> CLIENT: 521 5.2.1 : AOL will not accept delivery of this message.
2018-04-22 21:44:56 SMTP ERROR: DATA END command failed: 521 5.2.1 : AOL will not accept delivery of this message.
SMTP Error: data not accepted.
Message could not be sent. Mailer Error: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: : AOL will not accept delivery of this message. SMTP code: 521 Additional SMTP info: 5.2.12018-04-22 21:44:56 CLIENT -> SERVER: QUIT
2018-04-22 21:44:56 SERVER -> CLIENT:
2018-04-22 21:44:56 SMTP ERROR: QUIT command failed:
I'm assuming I must have gotten the server, port and SMTPSecure settings wrong but can't figure what they should be. By the way, with the proper changes to server, port and SMTPSecure the code works for outlook.com.
This is running on MS Windows 10 desktop with Apache/2.4.27 (Win64) and PHP Version 7.0.9.
This article has the official SMTP server to use (unhelpfully hidden under the "POP3 & IMAP" section), and you appear to be using the correct details.
It may be a spam-filtering filtering problem; try setting $mail->XMailer = ' '; (there's a space in those quotes) to suppress the identification of PHPMailer.
This error seems to be very subjective on AOL's side - there are a zillion search results if you search for that error message, and you can see others sharing their frustration here and here
Otherwise I'd recommend contacting AOL postmaster support.
Try taking the word 'AOL' out of the display-name portion of your From address. Since most clients only show the display-name when listing mail, AOL doesn't like names that look like they might be from official AOL addresses.
Related
In the company I work for we use microsoft exchange server and ofcourse ms outlook to send and recieve email.
on andriod we use exchange application as following to access our mail.
I am trying to use the following code to send emails IN php:
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.dom-domain.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'username'; // SMTP username
$mail->Password = 'password123'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('username#dom-domain.com', 'Mailer');
$mail->addAddress('recname#yahoo.com', 'Joe User'); // Add a recipient
//$mail->addAddress('ellen#example.com'); // Name is optional
$mail->addReplyTo('username#dom-domain.com', 'Information');
//$mail->addCC('cc#example.com');
//$mail->addBCC('bcc#example.com');
//$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 = 'Here is the subject tls587';
$mail->Body = 'This is the HTML message body tls587 <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients tls587';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
but the page loads alot and I get this error:
2017-04-02 13:13:45 Connection: opening to mail.dom-domain.com:587, timeout=300, options=array ( ) 2017-04-02 13:14:48 Connection failed. Error #2: stream_socket_client(): unable to connect to mail.dom-domain.com:587 (Connection timed out) [/home/xxxxxxx/public_html/ml/PHPMailer/class.smtp.php line 294] 2017-04-02 13:14:48 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2017-04-02 13:14:48 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Keep noted that on your Android device you are mostly using Microsoft Active Sync via port 443. You do NOT use a native SMTP connection here via port 587 (which would be used via IMAP/POP3). The same is true for a plain Outlook connection where MAPI or MAPI over HTTP/Outlook Anywhere is used. Both do not use a native SMTP connection here and might be the reason why it isn´t working. BUT on your GMail Account you are mostly using IMAP as this isn´t an Exchange Server which support Microsoft Active Sync.
It might therefore possible that your Exchange Administrator didn´t configured the SMTP Connector for external Authenticated connections for Outlook users as this isn´t needed in your case and therefore disabled for security reasons. As you didn´t specify if you are the Exchange Administrator and which version you are using its not easy to give you a how to here. So instead of that, you should follow these howtos here from Microsoft:
Controlling SMTP Relaying with Microsoft Exchange
Configure authenticated SMTP settings for POP3 and IMAP4 clients in Exchange 2016
If you aren´t an Microsoft Exchange Administrator you can try to send emails via the Microsoft Exchange Webservices (see here). However as said above, the Exchange Administrator might run a special configuration here to secure the environment.
I am trying to use PHPMailer,
I have enabled opensll and it loads
I use XAMPP and PHPStorm
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP z88sm9679wrb.26 - gsmtp
CLIENT -> SERVER: EHLO PhpStorm 2016.1.2
SERVER -> CLIENT: 501-5.5.4 HELO/EHLO argument "PhpStorm 2016.1.2" invalid, closing connection.501 5.5.4 https://support.google.com/mail/?p=helo z88sm9679wrb.26 - gsmtp
SMTP ERROR: EHLO command failed: 501-5.5.4 HELO/EHLO argument "PhpStorm 2016.1.2" invalid, closing connection.501 5.5.4 https://support.google.com/mail/?p=helo z88sm9679wrb.26 - gsmtp
CLIENT -> SERVER: HELO PhpStorm 2016.1.2
SERVER -> CLIENT:
SMTP ERROR: HELO command failed:
SMTP NOTICE: EOF caught while checking if connected
SMTP Error: Could not connect to SMTP host.
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Here is my code
<?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587; //ssl : 465 --- tls:587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "te.professionnel#gmail.com";
//Password to use for SMTP authentication
$mail->Password = "*****";
//Set who the message is to be sent from
$mail->setFrom('te.professionnel#gmail.com', 'Abou May');
//Set an alternative reply-to address
//$mail->addReplyTo('replyto#example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('abou.may#gmail.com', 'Abou May');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
I have read lots of documentation, bu I cannot figure out the reason of this error.
Can someone givz me an example code?
What is wrong ?
I read all the section on troubleshooting
"SMTP Error: Could not connect to SMTP host."
This may also appear as SMTP connect() failed or Called Mail() without being connected in debug output. This is often reported as a PHPMailer problem, but it's almost always down to local DNS failure, firewall blocking (for example as GoDaddy does) or other issue on your local network. It means that PHPMailer is unable to contact the SMTP server you have specified in the Host property, but doesn't say exactly why. It can also be caused by not having the openssl extension loaded (See encryption notes below).
I also encounter this problem before.This is not the problem of PhpMailer.But in fact,this is cause by Gmail smtp is denied the connection,therefore you cant connect.
In order for you to solve this problem,you need to
Configure an OAuth2 app in Google Developer Console.
Step is here
If you still cant manage to solve it,I recommend you to use Postmark as your mail server,it is a lot easier to set up the connection.
Here is the guide for the setup of Postmark.For me is a lot easier.Hope it helps.
This is nothing to do with gmail or oauth.
The problem is this line:
CLIENT -> SERVER: EHLO PhpStorm 2016.1.2
When PHPMailer's SMTP client says hello to a server like this, by default it passes the name returned by the internal method serverHostname(). Normally this returns something like localhost.localdomain, or mymac.local (i.e. a real host name), but if that's not available, it tries to figure out what to use - and one of the things it falls back to is the $_SERVER['SERVER_NAME'] super global, which in this case contains PhpStorm 2016.1.2 (I'd guess because you're testing using PHPStorm's built-in web server?), which is not a valid host name, hence the error. This isn't a good move on PHPStorm's part and is probably worth reporting as a bug.
Fortunately you can override automatic determination of the client hostname using the Helo property, which exists precisely for occasions like this. Just do this:
$mail->Helo = 'my.host.name';
substituting either whatever your real host name is, or by calling some other function which gives a usable result.
I'm wondering what options are available to send an e-mail to my e-mail account when someone fills out my contact form. My setup is on AWS with an instance of Microsoft 2012 Server running.
I have IIS, PHP5.6 and have a local SMTP server running and working (I've successfully sent test e-mails on my local environment). It seems no matter what I attempt to try and send my contact form data via e-mail, it fails.
I've tried using Pear and PHPMailer, both always throw errors. I've tried troubleshooting these errors for the past 8 hours via the documentation and scouring websites (including Stack Overflow). I'm stuck and don't know what to attempt next. Is there something I'm missing like another option? This is my first time setting up my own server and it's been a huge hassle (although I think it will pay off in the end once I understand everything more). If PHPMailer is what I need to be using I can paste in my code, I've been working of the gmail example.
The current error I have with PHPMailer:
2016-01-01 01:45:32 CLIENT -> SERVER: EHLO www.xeno-studios.com
2016-01-01 01:45:32 CLIENT -> SERVER: STARTTLS 2016-01-01
01:45:32 SMTP Error: Could not connect to SMTP host. 2016-01-01
01:45:32 CLIENT -> SERVER: QUIT 2016-01-01 01:45:32 SMTP ERROR: QUIT
command failed: 2016-01-01 01:45:32 SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer
Error: SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
//example.php
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
$mail->Host = gethostbyname('smtp.gmail.com');
$mail->Port = 587; // or 587
$mail->IsHTML(true);
$mail->Username = "myemail#gmail.com";
$mail->Password = "gmailpass";
$mail->SetFrom("myemail#gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("recipient#gmail.com");
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
This must have been failing because of the Google smtp server. Apparently they have been changing the way people get authenticated which could be part of the reason I was getting errors. I ended up looking into AWS SES for my mail server setup and used those credentials in my PHPMailer function. It was rather easy to setup and worked like a charm.
Apologies for adding to the collection of PHPMailer / Gmail question. I've read them all, and still can't get this to work. First the error message:
2015-03-25 16:22:44 Connection: opening 2015-03-25 16:22:54 SMTP
ERROR: Failed to connect to server: A connection attempt failed
because the connected party did not properly respond after a period of
time, or established connection failed because connected host has
failed to respond. (10060) SMTP connect() failed. Message was not
sent. Mailer error: SMTP connect() failed.
This code is the same that I have used many times to successfully send emails from a secureserver.net account, so I'm pretty confident that the script is solid. The problem must be in the gmail settings that I am trying to use(?).
try {
$mail = new PHPMailer(true);
$mail->IsSMTP(); // Using SMTP.
$mail->CharSet = 'utf-8';
$mail->SMTPDebug = 2; // Enables SMTP debug information - SHOULD NOT be active on production servers!
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = 'true'; // Enables SMTP authentication.
$mail->Host = "smtp.gmail.com"; // SMTP server host.
$mail->Port = 587; // Setting the SMTP port for the GMAIL server.
$mail->Username = "XXXXXXXXXX#gmail.com"; // SMTP account username (GMail email address).
$mail->Password = "XXXXXXXXXX"; // SMTP account password.
$mail->AddReplyTo('XXXXXXXXXX#gmail.com', 'me'); // Use this to avoid emails being classified as spam - SHOULD match the GMail email!
$mail->AddAddress('someone.else#gmail.com', 'Someone Else'); // Recipient email / name.
$mail->SetFrom('XXXXXXXXXX#gmail.com', 'me'); // Sender - SHOULD match the GMail email.
$mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
$mail->Body = 'Test Body';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
// $mail->MsgHTML($message);
$mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
I've also tried port 465/ssl (and even 25, although this almost certainly won't work). I have verified with telnet that I can reach port 587:
telnet smtp.gmail.com 587 Trying 2607:f8b0:4001:c11::6c... Connected
to gmail-smtp-msa.l.google.com. Escape character is '^]'. 220
mx.google.com ESMTP f1sm1137441igt.14 - gsmtp
What am I missing? I've been over this for hours, and I don't see anything wrong. Thanks!
Have you checked the troubleshooting guide?
Use SMTPDebug = 4 for debugging low-level connection (as opposed to SMTP) problems.
Are you sure you're using latest PHPMailer? Your code looks like it's from an old example.
It would be good to eliminate PHPMailer from the test, as I suspect your problem is lower level. Write a simple script that just does an fsockopen to port 587 and reads from it, like this:
<?php
$fp = fsockopen('tcp://smtp.gmail.com', 587, $errno, $errstr, 10);
echo fgets($fp, 128);
fclose($fp);
If that works, you will see something like 220 mx.google.com ESMTP eo1sm5152802wib.16 - gsmtp from that.
If that doesn't work, suspect things like php.ini settings, disabled functions, missing extensions etc.
I am using this code to try to send email using SMTP, but I have an error
<html>
<head>
<title>PHPMailer - SMTP basic test with authentication</title>
</head>
<body>
<?php
//error_reporting(E_ALL);
phpinfo();
require("../class.phpmailer.php");
require("../class.smtp.php");
define("PHPMAILERHOST",'smtp.gmail.com');
date_default_timezone_set('Asia/Tehran');
$mail = new PHPMailer();
ini_set('display_errors', 1);
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->Port = "465"; // SMTP Port
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure= "ssl"; // SMTP connection type
/************************************************** *********************************/
/************************************************** *********************************/
$mail->Username = "XXXXXXXXXX#gmail.com"; // SMTP username
$mail->Password = "XXXXXX"; // SMTP password
// Send email to :
$mail->AddAddress("masoudy.maryam#gmail.com"); // will receive the test email
/************************************************** *********************************/
/************************************************** *********************************/
//$mail->AddAddress("second-receiver#gmail.com", "Josh Adams");
//$mail->AddReplyTo("example#gmail.com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
//$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 = "hahahahahahahahahahhahhahahahhahahha";
$mail->Body = '<html><meta http-equiv="content-type" content="text/php; charset=utf-8"/><body>
layay layayya رسید بگو
</body></html>
';
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
</body>
</html>
this code have not any problem in local i could send email in local (wamp server) but in server i have errors:
SMTP Error: Could not connect to SMTP host. Message could not be sent.
Mailer Error: SMTP Error: Could not connect to SMTP host.
I'm sure that ssl port is enable i call phpinfo() i had this result
please help me
In light of all of the comments above, it sounds like there may be some problem with the local SMTP server on the machine that your PHP is running on. You can try a few tests from the command line (like the ones mentioned above) to troubleshoot. Or, you might want to simply work around the local SMTP server on this machine, by using phpmailer to send outgoing mail by way of a remote SMTP relaying server. If you have a gmail account, you can use smtp.gmail.com, or you can use any other SMTP server that you have access to. phpmailer is simple to setup - just a few PHP files to copy to your server. See https://github.com/PHPMailer/PHPMailer. Then, you can start sending mail using the simple example at the github page above as a boilerplate. phpmailer will also handle all of your MIME encoding, so you don't have to do it from scratch like you're doing.