i'm developing a website to send reminders to employees in my company using phpmailer, the emails are working fine, but when i connect to the workplace internet connection it stops working with no errors but:
Connection: opening to smtp.mail.yahoo.com:587, timeout=300, options=array ( )
i'm guessing it might be a closed port, so i tried using 587 and 25.
i'm not that good in networking, is there's any way i can know what is the exact error?
function SendOutlook(){
//$recipient = 'xxxxx#yahoo.com';
require 'PHPMailer/PHPMailerAutoload.php';
$Emp_recipient = "employee#yahoo.com";
$mail = new PHPMailer;
$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = "smtp.mail.yahoo.com"; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxxxx#yahoo.com'; // SMTP username (server username)
$mail->Password = 'xxxxx'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('xxxxx#yahoo.com', 'One');
$mail->addAddress($Emp_recipient,"name"); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'test';
$mail->Body = "scheduled on your outlook calender";
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit();
}else {
echo '<p>Message has been sent</p>';
}
echo !extension_loaded('openssl')?"Not Available":"Available";
}
Related
I tried to create a mail-confirm signup system but when I signup, database save my data but there is a error that says:
SMTP Error: Could not authenticate.
note: I am using class.phpmailer.php
I could not understand the problem. Here is my code:
sendmail.php
<?php
require 'PHPMailerAutoload.php';
function send_mail($sendto, $subject, $body)
{
$mail = new PHPMailer;
//$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 = '**.****.****#gmail.com'; // SMTP username
$mail->Password = '**********'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('e.d***.c**#gmail.com', 'Restro | Restaurants in Mumbai');
$mail->addAddress($sendto); // Name is optional
$mail->addReplyTo('e.d****.c***#gmail.com', 'Restro | Restaurants in Mumbai');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = 'Please open this on Chrome';
if (!$mail->send()) {
//echo 'Message could not be sent.';
return 'Mailer Error: ' . $mail->ErrorInfo;
} else {
return 'Message has been sent';
}
}
Use port 465
port 587 if your client begins with plain text before issuing the STARTTLS command.
I'm using php mailer for mail triggering.
Its working fine. But I gave 2 to 5 recipients, it sends the mail to only one recipient. In future, I have to trigger a mail to nearly 100 recipients..
I've shared my code below.. Please check it..
require 'phpmailer/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 = 'karthick****#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
$mail->setFrom('karth*******#gmail.com', 'A**n');
$addresses = explode(',',$emailM);
foreach ($addresses as $address) {
$mail->AddAddress($address);
}
$mail->isHTML(true);
$mail->Subject = 'Need for '.$keyword.'';
$mail->Body = 'Hi,The Message';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Qoute has been sent to all the Manufacturers';
echo "$address";
}
You're code looks like it should be doing the trick. Make sure that $address doesn't contain any whitespace for the entries. For safe measure, add the trim()
function.
$mail->AddAddress(trim($address));
If that does not work, make sure that you're recipient addresses are real.
Additionally, in case the privacy of the recipients is of concern, I would recommend you use AddBCC() instead of AddAddress() so that their addresses are not revealed.
A basic idea is that make different connection (object) for each your mailing address like below if You don't have so much addresses in your array.
require 'phpmailer/PHPMailerAutoload.php';
$addresses = explode(',',$emailM);
foreach ($addresses as $address) {
$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 = 'karthick****#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
$mail->setFrom('karth*******#gmail.com', 'A**n');
$mail->AddAddress($address);
$mail->isHTML(true);
$mail->Subject = 'Need for '.$keyword.'';
$mail->Body = 'Hi,The Message';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Qoute has been sent to all the Manufacturers';
echo "$address";
}
UPDATE :
The second idea is that you can remove recepients each time and add new one and then send like below
require 'phpmailer/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 = 'karthick****#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
$mail->setFrom('karth*******#gmail.com', 'A**n');
$addresses = explode(',',$emailM);
foreach ($addresses as $address) {
// for clear last recipients
$mail->ClearAllRecipients( )
$mail->AddAddress($address);
$mail->isHTML(true);
$mail->Subject = 'Need for '.$keyword.'';
$mail->Body = 'Hi,The Message';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Qoute has been sent to all the Manufacturers';
echo "$address";
}
}
Here is my code:
require 'phpmailertesting/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'send.one.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'myemailhidden'; // SMTP username
$mail->Password = 'mypasswordhidden'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = 'myemailhidden';
$mail->FromName = 'My Name';
$mail->addAddress('example#example.com'); // Name is optional
$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';
$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 have tried changing the port and the type of secure connection to "TSL" and "SSL" and nothing. Ive looked at the answers already and none of them solve it. Any answers? Thanks
I enabled the SMTP debugger and this is what it said "Connection: opening to ssl://send.one.com:465, t=300, opt=array ( ) 2014-12-15 15:46:40 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2014-12-15 15:46:40 SMTP connect() failed"
Your hosting company, one.com, blocks outgoing mail ports intentionally to restrict malicious PHP scripts. The send.one.com address is meant for external mail clients such as your mobile phone, email client, etc. and not for internal mailing scripts from your website.
As per their support document concerning sending emails from your website, you must change the host to their internal SMTP address, mailout.one.com - since this is an internal relay, you must also use port 25 and disable any security such as TLS or SSL. You must also disable authentication.
Here is the correct configuration:
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mailout.one.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Authentication must be disabled
$mail->Username = 'myemailhidden';
$mail->Password = ''; // Leave this blank
$mail->Port = 25; // TCP port to connect to
The other solutions did not work for me; this one did:
$mail->isSMTP();
$mail->Host = 'mailout.one.com';
$mail->SMTPAuth = false; // disable SMTP authentication
$mail->Username = '[your one.com-email]';
$mail->Password = '[your one.com-email password]';
$mail->SMTPSecure = ''; // leave this blank!
$mail->Port = 25;
Let me know if it helped you, too!
New to SO, so cant vote gold on you #sjagr
Had this problem, and as I use one.com, there were no biggey with the solution from #sjagr :)
You can try this full output in you file, and make sure to link the required docs.
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = "mailout.one.com";
$mail->SMTPAuth = false;
$mail->Port = 25;
$mail->From = 'your#domain.se';
$mail->FromName = 'Mailer';
$mail->addAddress('sendtothis#domain.se');
$mail->addReplyTo('ireply#domain.se', 'Information');
$mail->addBCC('bcc#example.com');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'hejehej';
$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, ja e fan inte tom';
} ?>
I used this coding to send mail using gmail, but am getting the below error, here when i removed the ssl part, its working, but i dint receive any emails(checked inside spam also). Any other problems ?
$mail = new phpmailer;
$mail->IsSMTP(); // telling the class to use SMTP
$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->Username = "un"; // GMAIL username
$mail->Password = "pwd"; // GMAIL password
$mail->SetFrom('test#gmail.com', 'Bharanidharan');
$mail->AddReplyTo("test#gmail.com","Vishal Kumar");
$mail->AddAddress("test#gmail.com","Bharani");
$mail->Subject = "Hey, check out";
$body = "hey, check email";
$mail->MsgHTML($body);
$address = "test#gmail.com";
$mail->AddAddress($address, "test");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
Enable the mod_ssl in Apache (search the config file) and the openssl PHP extension (check php.ini)
Please can some one suggest me codes to send mails using yahoo smatp, and php..
require("class.phpmailer.php"); // be sure to change this to your location!
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.mail.yahoo.com"; // sets yahoo as the SMTP server
$mail->Port = 25; // set the SMTP port
$mail->Username = "sumthing#yahoo.com"; // yahoo username
$mail->Password = "password"; // yahoo password
$mail->From = "sumthing#yahoo.com";
$mail->FromName = "myname";
$mail->AddAddress("you#example.com");
$mail->Subject = "Test PHPMailer Message";
$mail->Body = "Hi! \n\n This was sent with phpMailer_example3.php.";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
This code is giving me errrors 'Could not connect to SMTP host".
Many of the sites providing SMTP do not support SSL (SMTP-S). If supported is usually in different port, such as 465. Connecting to 465 often fails. Try commenting out
$mail->SMTPSecure = "ssl"
Try also first without authentication to make sure the connection works.