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.
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 am trying to send the messages through "email to sms" gateway for that i have the following code:
<?php
require 'mailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$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-email>#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('<my-email>#gmail.com', 'abhishek');
$mail->addAddress('<mob-no>#bplmobile.com'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$bodyContent = 'Hello world';
$mail->Subject = 'Demo Subject';
$mail->Body = $bodyContent;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
I have got the gateway from here. I have tried all the gateways in the link, but the message doesn't seems to be deliver.
Email to SMS gateways are a thing of past. Today none of the providers provide email address based on number. Best solution is to use a sms gateway like twilio.
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";
}
The email address and password is definitely correct. The script was working until yesterday. Now we receive the following error:
Mailer Error: SMTP connect() failed.
We can login to the Google email address. I can send emails via SMTP in Outlook. We have Google Apps Free Edition, so it is not possible to contact Google.
Does anyone have any ideas as to why the connection has just stopped working? Thank you.
mail->SMTPDebug = 2;
$mail->IsSMTP(true); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = $Username; // SMTP account username
$mail->Password = $Password;
$doc_dir = 'pdf/';
$mail->From = $From;
$mail->FromName = $FromName;
$mail->addAddress($email);
$mail->WordWrap = 50;
$mail->addAttachment($doc_dir.$FileName);
$mail->isHTML(true);
$mail->Subject = 'Your '.$warehouse_name.' Order Has Shipped';
$mail->Body = $Message;
$mail->AltBody = 'Racquet Depot UK';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
};
The host had made an SMTP restriction which caused the issue. Otherwise, the code is correct.
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';
} ?>