What's the configuration to be able to send emails from my localhost to hotmail using PHPMailer.
public static function sendMail($subject, $body, $address) {
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.live.com';
$mail->Port = 587;
$mail->isHTML();
$mail->Username = 'myMail#hotmail.com';
$mail->Password = 'myMailPass';
$mail->SetFrom('no-reply#gmail.com');
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($address);
$mail->Send();
this is what I have but I can't send emails. It says email was sent, it's in the queue, but it's never delivered.
Related
While running the PHPMailer in localhost mail will be sending but while hosting the PHPMailer shows the error as SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting. please help me.
here is my code
<?php
//include PHPMailerAutoload.php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = 'mail#gmail.com';
$mail->Password = 'password';
$mail->setFrom('mail#gmail.com', 'mail');
$mail->addAddress('mail#gmail.com');
$mail->Subject = 'SMTP email test';
$mail->Body = 'Thanks for commenting';
if ($mail->send())
echo "mail is sent";
else
echo $mail->ErrorInfo;
?>
Ok let's make it clearly :
Make sure your SMTP Port code is same with SMPT port in your host
Auth to your account is not wrong
Check phpmailer class are success to call like vardump or something else
Sample of my Code :
require(https://example.com/PHPMailerAutoload.php');
require(https://example.com/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'mail.example.com';
$mail->SMTPAuth = TRUE;
$mail->Username = 'customer_service#example.com';
$mail->Password = 'blablabla';
$mail->From = 'customer_service#example.com';
$mail->setFrom('customer_service#example.com', 'My Cool Website');
$mail->AddAddress('recipient#destination.com', 'Recipient Full Name');
$mail->WordWrap = 70;
$mail->Subject = 'PHP Mailer';
$mail->Body = 'Awesome';
$mail->IsHTML(TRUE);
I'm using PHPMailer and am unable to send emails when configuring it to use my SendGrip credentials. Here is my sendEmail function:
public function sendEmail($to, $subject, $message)
{
$mail = new \PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.sendgrid.net';
$mail->SMTPAuth = true;
$mail->Username = 'apikey';
$mail->Password = 'removed';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('removed#email.com');
$mail->addAddress($to);
$mail->isHTML(false);
$mail->Subject = $subject;
$mail->Body = $message;
if(!$mail->send()) {
throw new MailerException();
}
}
Is there anything obviously wrong with this function?
Thanks,
Thanks in advance.
Below is code from PHPmailer (https://github.com/Synchro/PHPMailer) which is giving me a few problems. It works along side this PHP sign-up (http://www.codingcage.com/2015/09/login-registration-email-verification-forgot-password-php.html). I know it works other then the email because the table in the database does recieve the values. I can manually update the table and and allow myself to log-in. It does send out a Error 500 page.
function send_mail($email,$message,$subject)
{
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->AddAddress($email);
$mail->Username = "EMAIL#gmail.com";
$mail->Password = "PASSWORD";
$mail->SetFrom('robert.m.smith112#gmail.com','Coding Cage');
$mail->AddReplyTo("robert.m.smith112#gmail.com","Coding Cage");
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
}
I am trying to send email using PHPMailer with Yii with no success. Here are my Settings:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "mymail#gmail.com";
$mail->Password = "************";
$mail->SMTPSecure = 'ssl'
Here is my Controller Function:
$mail->IsHTML(true);
$mail->From = Yii::app()->params['adminEmail'];
$mail->FromName = empty($_POST['EmailForm']["from_name"]) ? Yii::app()->params['emailFrom'] : $_POST['EmailForm']["from_name"];
$mail->Subject = $subject;
$mail->Body = nl2br($message) . $mail->Body;
$mail->AddAddress($to);
$mail->AddCC($cc);
$mail->send();
But When I try to send an email the following error pops up:
The following email address failed myemail#gmail.com. called mail()
without being connected.
Please help me solve this!
with smtp.gmail.com i think you should use this setting:
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
SMTP -> ERROR: DATA not accepted from server: 550 This message was classified as SPAM and may not be delivered
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.cc.com";
$mail->SMTPAuth = true;
$mail->Username = "info#cc.com";
$mail->Password = "cc";
$mail->From = "cc.com"." <info#cc.com>";
$mail->AddReplyTo("cc1#gmail.com");
$mail->FromName = "info#cc.com";
$mail->AddAddress($climail);
$mail->AddCC("cc1#gmail.com");
$mail->Sender="info#cc.com";
$mail->IsHTML(true);
$mail->WordWrap = 70;
$mail->Subject = $sub;
echo $meegate;
$mail->Body=$meegate;
$mail->SMTPDebug = 1;
$mail->Send();
Error occurring while sending mail.. mail not sent..
You need to set SMTP host and also the port I guess which is 465:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "info#gmail.com";
$mail->Password = "cc";
$mail->From = "gmail.com"." <info#gmail.com>";
$mail->AddReplyTo("cc1#gmail.com");
$mail->FromName = "info#gmail.com";
$mail->AddAddress($climail);
$mail->AddCC("cc1#gmail.com");
$mail->Sender="info#gmail.com";
$mail->IsHTML(true);
$mail->WordWrap = 70;
$mail->Subject = $sub;
echo $meegate;
$mail->Body=$meegate;
$mail->SMTPDebug = 1;
$mail->Send();