Trying to send using PHP Mailer and getting following error - php

This is my configuration
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "gator4102.hostgator.com";
$mail->Port = 465;
$mail->Username = 'test#some.com';
$mail->Password ='jyghvbjyhj';
It throws following error
SMTP -> ERROR: HELO not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedLanguage string failed to load: tls
Mail gets delivered though sometimes. Please help.

Change:
$mail->Port = 465;
To:
$mail->Port = 587;
For tls, 587 port is used.

If you are using
$mail->SMTPSecure = "tls";
Then your setting should be as following :
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "gator4102.hostgator.com";
$mail->Port = 587;
$mail->Username = "yourusername#abc.com";
$mail->Password = "yourpassword";

If you get response from server, it's already good enough. This means that you connect to server successfully.
You are probably trying to connect to the port on which another server application is listening. First, check again that you connect to port on which SMTP server is listening and waiting for TLS connection. Try to connect to another server to locate problem. Also, you can try another PHP library.

Related

Why can't I connect to the gmail SMTP server using tls?

My target is to send an email to myself using PHPMailer. I am using Gmail SMTP as a start (I have enabled less secure app access and disabled two factor authentication), and am trying to connect from localhost (using MAMP). This is my code:
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer-master/src/Exception.php';
require 'PHPMailer-master/src/PHPMailer.php';
require 'PHPMailer-master/src/SMTP.php';
$mail = new PHPmailer(true);
try {
$mail->SetFrom('myemail','myname');
$mail->AddAddress('myemail','mynickname');
$mail->Body = 'There is a great disturbance in the Force.';
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = 'tls';
$mail->Username = 'myemail#gmail.com';
$mail->Password = 'mypassword';
$mail->Port = 587;
$mail->Send();
}
catch (Exception $e){
echo $e->errorMessage();
}
This gives me a SMTP connect() failed error. I checked the troubleshooting page for this and have found that this error occurs when there is a Firewall or DNS failure, so I have tried disabling the firewall on my computer altogether, but to no avail. What could be the problem?
It is worth noting that I have tried connecting to the smtp server on cmd using telnet smtp.gmail.com 587 and that didn't work either. What could be the problem here?
Edit: I changed $mail->SMTPSecure = 'tls'; and $mail->Port = 587; to $mail->SMTPSecure = 'ssl'; and $mail->Port = 587; respectively it worked. Why does tls not work?
Use
$mail->SMTPDebug = 4;
In the try{ section to help narrow down the errors

Phpmailer working locally, but not working on server. Getting error: escapeshellcmd() has been disabled for security reasons

$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '********#gmail.com';
$mail->Password = '********';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
When I am using IsSmtp() message does not send it will stop on send.
When I remove IsSmtp() mail send properly but it gives the following error:
escapeshellcmd() has been disabled for security reasons
Just add $mail->isSMTP(); That will avoid using escapeshellcmd().

How to find the information from the hosting service 1&1 in order to send emails using PHP mailer?

I currently have a website which uses PHPmailer to send emails. I am hosting it with 1&1.fr, but cannot find the information in order to actually send emails. Here is the following information that I need:
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
On the 1&1.fr website, they give out the following information:
In the image, they specify multiple ports as well as an entrance/exit server; which ones am I supposed to pick and enter into my PHP file.
The rest of my code works fine (it works when I use my gmail account using 000webhost).
Any help would be greatly appreciated.
// define the $mail // just in case you miss it as it is missing in your code.
$mail = new PHPMailer();
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2; // this is to enable debug if there are errors
$mail->isSMTP(); //Tell PHPMailer to use SMTP
//Set the hostname of the mail server
$mail->Host = 'auth.smtp.1and1.fr';
// Enable authentication so you must provide username and password for SMTP authentication
$mail->SMTPAuth = true;
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Here you are telling to use a secure connection with TLS/SSL
//Set the SMTP port number
$mail->Port = 587; // if specified tls. try also 465 as defined in the picture you post
// TCP port for secure connections. 465 is the secure port for outgoing
// emails and 993 is for incoming email using IMAP. If you use POP3 the
//incoming emails are received on 995 port number.
Hope now is more clear.

phpmailer SMTP client information

I am updating some contact forms on several websites i made, and i am using phpmailer for it.
I'm using the SMTP method where you fill in the username and password of the email client where it needs to send to, like below:
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mailout.one.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'info#company.com'; // SMTP username
$mail->Password = 'mypass'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('info#company.com', $email);
$mail->addAddress('info#company.com');
$mail->addReplyTo(''.$email.'');
My problem is i have to get my client his/hers emailaddress with their password, how could i solve this without asking my clients for their email information.

PHPMailer Gmail SMTP works on localhost but not on server

This is what I get when running the PHPMailer script on the production server. PHPMailer version is 5.1
SMTP -> ERROR: Failed to connect to server: Network is unreachable (101)
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error:
Could not connect to SMTP host
PHPMailer Configuration
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "xxxx#gmail.com";
$mail->Password = "xxxx";
Using this config, it worked perfectly on localhost running XAMPP.
What I Tried
$mail->SMTPSecure = "tls"; // no luck
$mail->Host = "ssl://smtp.gmail.com"; // no luck
$mail->SMTPKeepAlive = true; // no luck
$mail->Port = 587; // no luck
$mail->Port = 25; // no luck
I tried with various combinations of the above but still I got the error message displayed above.
FYI, my localhost is on Windows while the server is on Linux. Don't know if that would cause a problem, but just wanted to put it out there.

Categories