PHPMailer problem connecting to smtp.mail.emea.microsoftonline.com - php

I'm getting the following error when trying to send an email from a web server running W2K server 2003 to smtp.mail.emea.microsoftonline.com
SMTP -> FROM SERVER:220 smtp.mail.emea.microsoftonline.com Microsoft ESMTP MAIL Service ready at Thu, 8 Oct 2009 01:00:53 -0700
SMTP -> FROM SERVER: 250-smtp.mail.emea.microsoftonline.com Hello [78.109.167.122] 250-SIZE 31457280 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-AUTH 250-8BITMIME 250-BINARYMIME 250 CHUNKING
SMTP -> ERROR: AUTH not accepted from server: 504 5.7.4 Unrecognized authentication type
SMTP -> FROM SERVER:250 2.0.0 Resetting
SMTP Error: Could not authenticate.
Can anyone spot what is wrong? I have the the following set in php.ini as well:
[mail function]
; For Win32 only.
SMTP = smtp.mail.emea.microsoftonline.com
smtp_port = 587
; For Win32 only.
sendmail_from = enquiries#domain.com
require_once('class.phpmailer.php');
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Host = "smtp.mail.emea.microsoftonline.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
//$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Port = 587; // set the SMTP port for the server
$mail->Username = "enquiries#domain.com"; // username
$mail->Password = "Password"; // password
$mail->AddReplyTo('enquiries#domain.com', 'First Last');
$mail->AddAddress('myemail#gmail.com', 'John Doe');
$mail->SetFrom('enquiries#domain.com', 'First Last');
$mail->AddReplyTo('enquiries#domain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('examples/contents.html'));
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}

Try these manual steps first to see if you can connect at all:
http://technet.microsoft.com/en-us/library/aa995718(EXCHG.65).aspx
Also, this page:
http://www.gilham.org/Blog/Lists/Posts/Post.aspx?List=aab85845%2D88d2%2D4091%2D8088%2Da6bbce0a4304&ID=665
says that: The FROM address must use a SMTP domain of type “Authoritative” – this can be confirmed in Microsoft Online Administration Center, under the Users - Domains tab.

I've same problem some month ago. And the error caused by our SMTPSecure is used ntlm.
Don't forget to relay your mail server which it's allow to sent and receive mail from the web.
And recheck your account email and the password that is it right?

Related

Having Issues Connecting To Webmail Server Using My Phpmailer

Have been trying to use phpmailer to send mail to my business mail purchase from monovm.com hosting provider with the below codes
<?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;
use PHPMailer\PHPMailer\SMTP;
require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';
require 'src/POP3.php';
//Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = "smtp.haygoldinternational.com";
$mail->Port = 587; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = "office#haygoldinternational.com"; //SMTP username
$mail->Password = "mypassword"; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
//TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
if(isset($_POST['btnSubmit']))
{
$mail->setFrom('office#haygoldinternational.com', 'HAYGOLD');
$mail->addAddress('office#haygoldinternational.com', 'HAYGOLD'); //Add a recipient
$mail->addReplyTo("toheebabiodun03#gmail.com", "Abiodun");
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = "TESTING";
$mail->Body = "Just testing";
$mail->send();
echo 'Message Sent Successfully';
}
}
catch (Exception $e)
{
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
the error i keep getting is this
2021-04-03 15:37:28 SERVER -> CLIENT: 220 us2.outbound.mailhostbox.com ESMTP Postfix
2021-04-03 15:37:28 CLIENT -> SERVER: EHLO haygoldinternational.com
2021-04-03 15:37:28 SERVER -> CLIENT: 250-us2.outbound.mailhostbox.com250-PIPELINING250-SIZE 41648128250-VRFY250-ETRN250-STARTTLS250-AUTH PLAIN LOGIN250-AUTH=PLAIN LOGIN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSN
2021-04-03 15:37:28 CLIENT -> SERVER: STARTTLS
2021-04-03 15:37:28 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
2021-04-03 15:37:28 CLIENT -> SERVER: QUIT
2021-04-03 15:37:28 SERVER -> CLIENT:
2021-04-03 15:37:28 SMTP ERROR: QUIT command failed:
SMTP Error: Could not connect to SMTP host.
Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.
What could have been the cause,i was able to use the same code to connect my gmail which work perfectly fine..
Please help a brother
Simpler than I suggested in my comment – the server you’re connecting to is not the one you asked to connect to. You asked for smtp.haygoldinternational.com but connected to us2.outbound.mailhostbox.com. This will make certificate verification fail, exactly as it should when it detects a name mismatch.
Either change your Host value to match it (if it’s expected), or find out why you’re being redirected there.

problem with PHPMAILER Could not connect to SMTP host

I Have Problem With PHPMAILER it's Work Good in localhost but in server give me error
PHPMAILER Code
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function sendMail($driver, $driverUser){
// Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'wastaapplication#gmail.com'; // SMTP username
$mail->Password = '*******'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('wastaapplication#gmail.com', 'Wasta Driver');
$mail->addAddress($driver, $driverUser); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'New Order';
$mail->Body = ' مرحبا ' . '<strong>' . $driverUser . '</strong>' . ' لديك طلبيه جديده برجاء مراجعه برنامج الطيارين ';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
Error
2019-04-30 05:14:51 SERVER -> CLIENT: 220-server.issgroups.org ESMTP Exim 4.91 #1 Tue, 30 Apr 2019 07:14:51 +0200 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2019-04-30 05:14:51 CLIENT -> SERVER: EHLO wastetkheer.com
2019-04-30 05:14:51 SERVER -> CLIENT: 250-server.issgroups.org Hello wastetkheer.com [138.201.107.252]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
2019-04-30 05:14:51 CLIENT -> SERVER: STARTTLS
2019-04-30 05:14:51 SERVER -> CLIENT: 220 TLS go ahead
SMTP Error: Could not connect to SMTP host.
2019-04-30 05:14:51 CLIENT -> SERVER: QUIT
2019-04-30 05:14:51
2019-04-30 05:14:51
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 trying change SMTPDebug To 1
& //$mail->isSMTP();
it's work good in local host not in server
I guess the problem is with the SMTP authentication, but I couldn´t find the problem.
Please search before posting as this has been answered many times before.
It's failing immediately after STARTTLS, indicating a TLS error. This is very common with gmail because their CA root certificates changed about a year ago to ones that are not present in many older OSs. It's working for you on localhost because your local OS does not have outdated CA certificates.
Read the troubleshooting guide which tells you exactly how to deal with this.
It could also be down to your ISP redirecting SMTP traffic to their own mail server, causing a certificate name mismatch - the guide provides ways of diagnosing the exact problem.

PHPMailer failed send to GMAIL

Battling PHPMailer for sending emails, not if my server configuration this wrong or my settings either mail or if my code is wrong. Here is the code I use
$nombre = $_POST['name'];
$email = $_POST['email'];
$mensaje = $_POST['mensaje'];
require 'vendor/PHPmailer/PHPMailerAutoload.php';
$mail = new PHPMailer(); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
$body .= "<b>Hola</b>";
try {
//$mail->Host = "mail.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->SMTPKeepAlive = true;
$mail->Mailer = "smtp";
$mail->Username = "test#mydomain.com"; // GMAIL username
$mail->Password = "12345678"; // GMAIL password
$mail->AddAddress($email, 'abc');
$mail->SetFrom('nhernandez#fullmecanic.com', 'def');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($body);
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
Config php.ini
[mail function]
SMTP = localhost
smtp_port = 25
extension=php_openssl.dll
Also configure my gmail account for non-secure everything I found in forums and it does not work and I get this application:
2016-05-03 19:58:37 CLIENT -> SERVER: EHLO mydomain.com 2016-05-03 19:58:37 CLIENT -> SERVER: AUTH LOGIN 2016-05-03 19:58:37 CLIENT -> SERVER: bmhlcm5hbmRlekBmdWxsbWVjYW5pYy5jbA== 2016-05-03 19:58:37 CLIENT -> SERVER: ODEzODI5My4u 2016-05-03 19:58:38 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 j80sm38623ywg.48 - gsmtp 2016-05-03 19:58:38 SMTP Error: Could not authenticate. 2016-05-03 19:58:38 CLIENT -> SERVER: QUIT 2016-05-03 19:58:38 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message Sent OK
If you look carefully, I after sending an email, print "Message Sent OK" and this appears, but also appears authentication error
Have you read Gmail XOAUTH2 Using Google API Client. Does it pertain to you?
Have you tried ping smtp.gmail.com and make sure you get a response from the server hosting your script?
Can also try port 587 instead.
Kind of just spit balling here based off their troubleshooting guide because I cannot test your set up.

PHPMailer SMTP ERROR: command failed

My code works when i use gmail has host, but for this project i have to use office365.com and i receive errors i do not know what to do with :
$mail = new PHPMailer;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->IsHTML(true);
$mail->Host = "smtp.office365.com"; // SMTP server
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Port = 587; // set the SMTP port for the GMAIL
$mail->Username = "username"; // username
$mail->Password = "password"; // password
//works with this (gmail)
//$mail->Host = "smtp.gmail.com"; // SMTP server
//$mail->SMTPSecure = "tls"; // sets the prefix to the servier
//$mail->Port = 587; // set the SMTP port for the GMAIL
//$mail->Username = "username"; // GMAIL username
//$mail->Password = "password"; // GMAIL password
$mail->setFrom('someEmailAdress');
$mail->addReplyTo("someEmailAdress");
$mail->AddAddress('someEmailAdress');
$mail->Subject = $_POST['ActivityType']." ".$_POST['DealerName'];
$mail->Body = $message;
$mail->WordWrap = 400;
$mail->IsHTML(true);
$mail->SMTPDebug = 2;
$mail->Send();
this is the error i get
12014-12-22 18:15:39 SERVER -> CLIENT: 220 BY2PR05CA022.outlook.office365.com
Microsoft ESMTP MAIL Service ready at Mon, 22 Dec 2014 18:15:39 +0000
2014-12-22 18:15:39 CLIENT -> SERVER: EHLO 192.168.1.53
2014-12-22 18:15:39 SERVER -> CLIENT: 250-BY2PR05CA022.outlook.office365.com Hello [24.37.210.58]
250-SIZE 78643200
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
2014-12-22 18:15:39 CLIENT -> SERVER: STARTTLS
2014-12-22 18:15:39 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2014-12-22 18:15:39 CLIENT -> SERVER: QUIT
2014-12-22 18:15:40 SERVER -> CLIENT:
2014-12-22 18:15:40 SMTP ERROR: QUIT command failed:
SMTP connect() failed
been tryin to figure out whats going on, but theres really not much to search upon with the "general" error of quit command failed. Especially when gmail works fine, could it be on office365 side?
btw outlook is most restricted of them all specially when it comes to html emails which is the one u have set in ur options ,try first to send to something like gmail ,maybe yahoo but again it have some restriction but gmail works everytime without any probs ,u can also use something like fakesmtp to catch the sent email.
sorry can't comment yet but try these
https://github.com/PHPMailer/PHPMailer/issues/189
or may be a selinux thing
http://osticket.com/forum/discussion/77982/resolved-smtp-office365-issue

phpmailer error on from email, PHP email

Ok I've been knocking my head against a wall, more for the overall problem of send an email thru PHP while specifying a mail server...
The solution I've made it the furthest with is phpmailer.
If there is a lightweight VERY easy solution - please suggest it.
here's what I have (obviously the u/p are NOT the real u/p - but they are in my code - the same account I get my gmail from in outlook, settings work FINE there...
Im using it as a test - because the smtp settings the client gave me didn't work - so I though I'd try something that I KNEW - DID work...
<?php
require 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "me#myDomain.com";
$mail->Password = "myPassword";
$mail->SetFrom('me#myDomain.com', 'James Test');
$mail->AddAddress('me#yahoo.com', 'John Doe');
$mail->Subject = 'PHPMailer SMTP test';
$mail->MsgHTML( 'This is a test' );
//Send the message, check for errors
if( !$mail -> Send() ) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
The error I'm getting
SMTP -> FROM SERVER:
CLIENT -> SMTP: EHLO dev.nps.com
SMTP -> FROM SERVER:
SMTP -> ERROR: EHLO not accepted from server:
CLIENT -> SMTP: HELO dev.nps.com
SMTP -> FROM SERVER:
SMTP -> ERROR: HELO not accepted from server:
CLIENT -> SMTP: AUTH LOGIN
SMTP -> ERROR: AUTH not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connected
The following From address failed: me#myDomain.com : Called Mail() without being connected
Mailer Error: The following From address failed: me#myDomain.com : Called Mail() without being connected
The dev.nps.com is simply a 'fake' domain I put in my host file, so i can distinguish my projects and not use 127.0.0.1 for everything... it's not specified in the code - so I'm not sure what's going on there, but the error seems to balk at the 'from email'... which again is weird because it shouldn't matter
Thanks for any help -

Categories