I have this code, which I want to use to send mails to my customers, PARAMETERS CENSORED (***):
include 'phpmailer/class.phpmailer.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->Host = "smtp.email.it";
$mail->Port = 25; // or 587 465
$mail->IsHTML(true);
$mail->SMTPSecure = 'tls';
$mail->Username = "***";
$mail->Password = "***";
$mail->SetFrom('***');
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress('***');
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
It connects but gives errors:
2013-10-13 09:13:25 CLIENT -> SERVER: EHLO *SITE_CENSORED*
2013-10-13 09:13:25 SMTP ERROR: EHLO command failed: Method EHLO is not supported.
2013-10-13 09:13:25 SMTP NOTICE: EOF caught while checking if connected
SMTP connect() failed.
Mailer Error: SMTP connect() failed.
Changing your port to 587 should work:
$mail->Port = 587; // or 587 465
I tried to telnet:
telnet smtp.email.it 25 //not working
telnet smtp.email.it 465 //not working
telnet smtp.email.it 587 //works
Related
I am trying to send an e-mail using this PHP code:
require("PHPMailer-master/src/PHPMailer.php");
require("PHPMailer-master/src/SMTP.php");
require("PHPMailer-master/src/Exception.php");
$from = "admin#mydomain.com";
$namefrom = "admin";
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->isSMTP(); // by SMTP
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true; // user and password
$mail->Host = "mail.gandi.net";
$mail->Port = 110;
$mail->Username = $from;
$mail->Password = "Password123";
$mail->CharSet = 'UTF-8';
// $mail->SMTPSecure = ""; // options: 'ssl', 'tls' , ''
$mail->setFrom($from,$namefrom); // From (origin)
$mail->addCC($from,$namefrom); // There is also addBCC
$mail->Subject = "Some subject";
$mail->AltBody = "Altenrate";
$mail->Body = "Heyheyhey";
$mail->isHTML(false); // Set HTML type
$mail->addAddress("hello#hotmail.com", "hello#hotmail.com");
if($mail->send())
{
echo "ok sent";
}
else
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
Thing is when using this code, it takes ages to load and ends up showing this error to me:
2018-12-09 20:50:24 CLIENT -> SERVER: EHLO www.mydomain.be
2018-12-09 20:53:24 SMTP ERROR: EHLO command failed: -ERR Unknown command.-ERR Disconnected for inactivity.
2018-12-09 20:53:24 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
Could someone explain me what the issue is and how to solve it?
Thanks!
you have the wrong settings according to :https://docs.gandi.net/en/gandimail/standard_email_settings/index.html
it should be
Outgoing (SMTP) server name: mail.gandi.net
Port: 25, 465 (with SSL) or 587 (with STARTTLS)
TLS or SSL: yes
SMTP Authentication: yes, using the same settings as for the POP / IMAP account
Hello traducerad,
$mail->isSMTP(); // by SMTP
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true; // user and password
$mail->Host = "mail.gandi.net";
$mail->Port = 110;
$mail->Username = $from;
$mail->Password = "Password123";
// $mail->SMTPSecure = "";
Port 110 is for incoming POP communication.
I think you want to send an email via SMTP.
Outgoing (SMTP) server name: mail.gandi.net
Port: 25, 465 (with SSL) or 587 (with STARTTLS)
TLS or SSL: yes
SMTP Authentication: yes, using the same settings as for the POP / IMAP account
FAQ from gandi.net
I want to send mail as outlook mail... but it shows the connection error and authentication error if some port numbers are changed... what wrong in my code....
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->CharSet = 'UTF-8';
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "outlook.office365.com";
$mail->Port = 993;
$mail->Username = "harish.reddy#skoopview.com";
$mail->Password = "XXXXXXX";
$mail->From = $from;
$mail->FromName= $FromName;
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->addAddress('harish.reddy#skoopview.com','harish');
if(!$mail->send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "E-Mail has been sent";
}
It shows error like this ... What i do ??
SERVER -> CLIENT: * OK The Microsoft Exchange IMAP4 service is ready.
[SABLAE4AUABSADAANgBDAEEAMAAwADUAMwAuAGEAcABjAHAAcgBkADAANgAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A]
* BYE Connection is closed. 13 2016-09-12 10:50:13 SMTP NOTICE: EOF caught while checking if connected 2016-09-12 10:50:13 SMTP Error:
Could not authenticate. 2016-09-12 10:50:13 SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer
Error: SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Thankyou....,
As George stated, the port should be 587. Make sure you are using TLS:
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp-mail.outlook.com;smtp.office365.com'; // Specify main and backup SMTP servers
But Outlook self-signs its own SSL/TLS certificate. Hence you need to add this piece of code as per https://github.com/PHPMailer/PHPMailer/issues/914:
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
I would try port 587 for SMTP - more details here: https://support.office.com/en-gb/article/POP-and-IMAP-settings-for-Outlook-Office-365-for-business-7fc677eb-2491-4cbc-8153-8e7113525f6c
I am trying sending email using PHPMailer without TLS, but PHPMailer still tries to send email with TLS even if I do not enable it:
include_once("PHPMailer-master\PHPMailerAutoload.php");
$To = 'some#site.com';
$Subject = 'Topic';
$Message = 'msg test';
$Host = 'site.com.br';
$Username = 'contact#site.com.br';
$Password = 'pass';
$Port = "587";
$mail = new PHPMailer();
$body = $Message;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = $Host; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
//$mail->SMTPSecure = 'ssl'; //or tsl -> switched off
$mail->Port = $Port; // set the SMTP port for the service server
$mail->Username = $Username; // account username
$mail->Password = $Password; // account password
$mail->SetFrom($Username);
$mail->Subject = $Subject;
$mail->MsgHTML($Message);
$mail->AddAddress($To);
if(!$mail->Send()) {
$mensagemRetorno = 'Error: '. print($mail->ErrorInfo);
echo $mensagemRetorno;
} else {
$mensagemRetorno = 'E-mail sent!';
echo $mensagemRetorno;
}
After send email, I got this message:
2016-09-01 21:08:55 CLIENT -> SERVER: EHLO www.johnmendes.com.br
2016-09-01 21:08:55 CLIENT -> SERVER: STARTTLS
2016-09-01 21:08:55 SMTP ERROR: STARTTLS command failed: 454 TLS not available due to temporary reason
2016-09-01 21:08:55 SMTP Error: Could not connect to SMTP host.
2016-09-01 21:08:55 CLIENT -> SERVER: QUIT
2016-09-01 21:08:55 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Erro ao enviar e-mail: 1
The server doesn't support ssl or tls.
Any idea?
This is covered in the PHPMailer docs. PHPMailer does opportunistic TLS - if the server advertises that it can do TLS (which yours does), it will use it automatically without you asking. You can disable this:
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
From the error message, it looks like this is a temporary problem on your hosting provider. You would see more info if you set $mail->SMTPDebug = 2;.
I can see you've based your code on an obsolete example, so make sure you have the latest version of PHPMailer and base your code on the examples supplied with it.
I had the same problem using one.com: SMTP 465 wasn't working.
I could using port 25 with this configuration in phpmailer:
$mail->Host = 'send.one.com';
$mail->SMTPAuth = true;
$mail->Username = "***";
$mail->Password = "******";
$mail->From = "***";
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = 'none';
$mail->Port = 25;
I am trying to send SMTP email using my gmail account details through PHP but every time I try got an error. I am writing my code so you can see what is the problem.
PHP:
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//Enable SMTP debugging.
$mail->SMTPDebug = 3;
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = "smtp.gmail.com";
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "username";
$mail->Password = "password";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "tls";
//Set TCP port to connect to
$mail->Port = 587;
$mail->From = "sender email";
$mail->FromName = "sender name";
$mail->addAddress("receiver email");
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
and the error I am facing:
2016-08-12 00:22:02 Connection: opening to smtp.gmail.com:587,
timeout=300, options=array ( ) 2016-08-12 00:22:16 SMTP ERROR: Failed to
connect to server: Network is unreachable (101) 2016-08-12 00:22:16 SMTP
connect() failed. Mailer Error: SMTP connect() failed.
any help would be appreciated.
Thanks
I am using this code to send emails using smtp:
require 'phpmailer/class.phpmailer.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->Host = "sr4.supercp.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "********";
$mail->Password = "********";
$mail->SetFrom("********");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("****#gmail.com");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
echo "<pre>";
echo print_r($mail);
}
else
{
echo "Message has been sent";
}
Getting this error:
2014-08-25 18:53:11 CLIENT -> SERVER: EHLO grabblaw.com
2014-08-25 18:53:11 SMTP ERROR: EHLO command failed:
2014-08-25 18:53:11 SMTP NOTICE: EOF caught while checking if connected SMTP connect() failed. Mailer Error: SMTP connect() failed.
I have spend entire day, but unable to make this work. Please help.
Please refer this url for more error detailed info: http://grabblaw.com/mail_template.php
Similar to this question SMTP error with PHPMailer EHLO not supported
Changing your port to 25 should work:
I tried to telnet:
telnet grabblaw.com 25 //works
telnet grabblaw.com 465 //hangs
telnet grabblaw.com 587 //no response
You're setting:
$mail->Port = 465; // or 587
but there's no accompanying:
$mail->SMTPSecure = 'ssl'; // or 'tls'
So you're trying to send unencrypted data to an encrypted connection, which will not work (it's one of the reasons that SMTP over SSL was deprecated 15 years ago). TLS on 587 is more resistant to this.
Switching to port 25 usually means you're giving up on encryption altogether, which isn't a good solution.