how do i make gmail accept the phpmailer from localhost and not prevent signing in?
how do i fix this error message
Message could not be sent.Mailer Error: SMTP connect() failed.
<?php
require 'PHPMailer-master\PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // 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 = 'my#gmail.com'; // SMTP username
$mail->Password = 'valid'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('my#gmail.com', 'me');
// Add a recipient
$mail->addAddress('their#gmail.com'); // Name is optional
$mail->addReplyTo('my#gmail.com', 'Information');
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
It seems a connection to Google SMTP on port 587 is not being made. Are you in a network where port 587 is blocked. You can simply check if a connection can be made by using this telnet command:
telnet smtp.gmail.com 587
You will get a response as shown in snapshot
The Telnet client in Windows is disabled by default, and needs to be enabled via Windows' Programs and Features:
Control Panel --> Programs --> Turn Windows features on or off, in the dialog that pops up check-mark "Telnet Client".
Or you can download Putty
Related
I'm using PHPMailer and have tried others but this simply does not work. I keep getting an error that the server keeps denying me access. Here is the example code used:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.office365.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xx#xx.com'; // SMTP username
$mail->Password = 'xxx'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from#example.com', 'Mailer');
$mail->addAddress('joe#example.net', 'Joe User'); // Add a recipient
$mail->addReplyTo('info#example.com', 'Information');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
I'm using the same settings as shown in their official documentation: https://support.office.com/en-gb/article/POP-and-IMAP-settings-for-Outlook-Office-365-for-business-7fc677eb-2491-4cbc-8153-8e7113525f6c
What seems to be an issue? I have checked online in a number of posts but nothing seems to be working. Any ideas?
For GoDaddy Office365 accounts you must use the GoDaddy secure SMTP server: smtpout.secureserver.net
Please refer to https://za.godaddy.com/help/server-and-port-settings-for-workspace-email-6949.
i have a issue sending mail using smtp mail class when i use my send email code using smtp in my local system at that time is working prefect but when i try that code in live server i got every time smtp connect failed error
i use this code for send mail using smtp mailer class
require 'mail/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'myemail#gmail.com';
$mail->Password = 'mypassword';
$mail->SMTPSecure = 'tls';
$mail->From = 'myemail#gmail.com';
$mail->FromName = 'Mailer';
$mail->addAddress('myemail#gmail.com', 'Joe User');
$mail->addAddress('myemail#gmail.com');
$mail->addReplyTo('myemail#gmail.com', 'Information');
$mail->addCC('myemail#gmail.com');
$mail->addBCC('myemail#gmail.com');
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';}
that is my code it working in local but not working in live server
i did all setting in my php.ini file like smtp and user password
but still not working so please give me proper solution or code that working in live server
this is error
2016-07-07 17:23:09 SMTP ERROR: Failed to connect to server: Network is unreachable (101) 2016-07-07 17:23:09 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
when you are in local at that time smtp.gmail.com its working but in live you need your server host address like mail.servername.com
You must first of all activate gmail accepting non secure apps
Use real email for sender and receiver 'Make sure of the password'
change
$mail->SMTPSecure = 'tls';
to
$mail->SMTPSecure = 'ssl';
//tls for localhost and ssl for host server 'onligne'
add port
$mail->Port = 465 ; // or 587
may work for you :)
hi my phpmailer is producing the following result when i execute my mailtest.php
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
i have gone through many questions about phpmailer in this forum but none has benefit me.
my mailtest.php
<?php
require ("/phpmailer/PHPMailerAutoload.php");
require ("/phpmailer/class.phpmailer.php");
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // 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 = 'thethih#gmail.com'; // SMTP username
$mail->Password = 'password.'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from#example.com', 'Mailer');
$mail->addAddress('thethih#gmail.com', 'Joe User'); // Add a recipient
$mail->addAddress('thethih#yahoo.com'); // Name is optional
$mail->addReplyTo('info#example.com', 'Information');
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
any help will be appreciated .. and it is in localhost.
On GitHub, PHPMailer says "Compatible with PHP 5.0 and later", but that may not be the case.
Try changing your version of PHP to 5.5 and see if that fixes the problem. You can change your version of PHP by going to control panel and clicking on PHP Configuration.
I'm trying to send a mail with PHPMailer (SMTP).
btw: the mail server is hosted by switchplus.ch...
But if i try to send a mail, I get the following error: "SMTP Error: Could not connect to SMTP host.
"
PHP code to send the mail:
<?php
require './mail/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.lordsofmahlstrom.li'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'support#lordsofmahlstrom.li'; // SMTP username
$mail->Password = 'secredPassword'; // SMTP password
$mail->SMTPSecure = 'tsl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('support#lordsofmahlstrom.li', 'Support');
$mail->addAddress('test#test.com', 'Tester'); // Add a recipient
$mail->addReplyTo('support#lordsofmahlstrom.li', 'Support');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
Does anyone know, what i did wrong?
it's $mail->SMTPSecure = 'tls';
not tsl
Also, if you want encryption, you have to connect to the host "smtp.mail-ch.ch" (Except of course you have you're own certificate.)
I just tried it and worked.
I'm getting error SMTP connect() failed phpmailer with localhost:
2015-09-10 09:34:48 Connection: opening to ssl://smtp.gmail.com:587,
timeout=300, options=array ( ) 2015-09-10 09:34:48 SMTP ERROR: Failed
to connect to server: (0) 2015-09-10 09:34: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
Is it phpmailer cannot run at localhost?
If I want really run at localhost how can I change the code?
I tried using mailto function is work for me but I want change whole thing.
can give any suggestion. I really want to learn it.
This is the code from github:
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 4; // 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 = 'mygmail#gmail.com'; // SMTP username
$mail->Password = 'mygmailpassword'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//$mail->Host = 'tls://smtp.gmail.com:587';
$mail->From = 'ikramlim#gmail.com';
$mail->FromName = 'Mailer';
$mail->addAddress('ikramlim#gmail.com', 'Joe User'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
PHPMailer is normally working on all systems.
I think you have an old openssl extension or your extension is not enabled. Check that with a phpinfo() if there is openssl enabled.
If not then enable it in your php.ini.
And the other way is that it seems that Google has some problems. When i try to send an Email at the moment i have connection problems with Thunderbird, too. I have to try it some times to connect to gmail.
My suggestion is that please try using 'tls' with port 587 instead of 'ssl' with port 587.
Also check whether you are including class.phpmailer.php(ie: require 'class.phpmailer.php';) , If you are doing please comment it and give a try.