I wish to send an email from my localhost with a valid smtp server. How should I configure the xampp server?
Here is my setup:
<?php
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->Username = 'myusername';
$mail->Password = 'my password';
$mail->Port = 587;
$mail->From = 'noreply#mysite.com';
$mail->FromName = 'mysite';
$mail->addAddress($email, $email);
$mail->isHTML(true);
$mail->Subject = 'Reset your Password';
$mail->Body = $content;
$mail->AltBody = $content;
$mail->SMTPSecure='tls';
?>
I'm getting error:
error:"called HELO without being connected".
All variables are set, but I left some out to shorten the question.
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);
SMTP -> ERROR: Failed to connect to server: An attempt was made to access a socket in a way forbidden by its access permissions. (10013) The following From address failed: info#gmail.com : Called Mail() without being connected
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = "gmail.com";
$mail->Password = "password";
$mail->From = "info#gmail.com";
$mail->FromName = "name.com";
$mail->Subject = "Register";
$mail->MsgHTML($userMsg);
$mail->AddAddress("email address", "name");
//$mail->AddAddress($rowUser['user_email'], $rowUser['user_name']);
$mail->send();
$mail->ClearAllRecipients();
TLS is correct, you could try SSL, change port to 465. Check your credentials. Is on-screen Username "gmail.com"?
Try this:
$mail = new PHPMailer();
$mail->IsSMTP(); // enable SMTP
$mail->CharSet = "UTF-8";
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "yourname#gmail.com";
$mail->Password = "yourpassword";
$mail->SetFrom("example#gmail.com");
$mail->Subject = $subject;
$mail->Body =$body;
$mail->AddAddress($email);
if(!$mail->Send())
{
return FALSE;
}
My problem is clear, PHPmailer is howing a long text before sending a mail, this is my code (function) :
function sendMail($content){
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true;
$mail->Port=465; // Enable SMTP authentication
$mail->Username = 'my mail'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'ssl';
$mail->SMTPDebug=true;
$mail->From = '****';
$mail->FromName = '******';
$mail->addAddress('******');
$mail->Subject = 'subject';
$mail->Body=$content;
$mail->AltBody ='testing';
$stat=$mail->send();
}
and this is a screenshot :
http://i.imgur.com/kLrC97q.jpg
Thanks
Sorry guys, I noticed that I should turn off debugging :
$mail->SMTPDebug=false;
I'm trying to configure email by using phpmailer and smtp but Authentication error appears.
Code below
include_once("phpmailer.php");
$mail = new PHPMailer();
$tarih = date("d.m.Y - H:i:s");
$mail->IsSMTP();
$mail->Host = "mail.golcukdh.gov.tr";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "username";
$mail->Password = "password";
$mail->IsHTML(true);
$mail->From = "email";
$mail->AddAddress("email");
$mail->Subject = "subject";
$mail->Body = "Body Part";
$mail->Send()
?>
I tried to configure this by using asp.net with these authentication information and it was successfull. But I want to use php, what is wrong ?
I am new in php i have a problem with my php mailer when i set
$Host = 'ssl://smtp.googlemail.com';
$Username = 'my gamil id';
$Password = 'my gmail password';
$Port = 465;
Php mailer working fine, but when i change it to
$Host = 'ssl://smtp.googlemail.com';
$Username = 'client gamil id';
$Password = 'client gmail password';
$Port = 465;
mailer not working and its shows an error message
Authentication Required
I am from India and client from US, so is there any changes in configuration file?
Please help me
Here is my mailer.php file
include 'phpmailer/class.config.php';
include 'phpmailer/class.phpmailer.php';
include 'phpmailer/class.smtp.php';
session_start();
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->IsHTML();
$mail->SMTPAuth = true;
if (MailConfig::$Debug) {
$mail->Host = MailConfig::$DebugHost;
$mail->Username = MailConfig::$DebugUsername;
$mail->Password = MailConfig::$DebugPassword;
} else {
$mail->Host = MailConfig::$Host;
$mail->Username = MailConfig::$Username;
$mail->Password = MailConfig::$Password;
}
$Subject = "Payment Received";
//////
/////////////
if (MailConfig::$Debug)
$receipientEmail = "client#example.com";
else
$receipientEmail = "client#example.com";
$Body = "A payment of $ " . $_POST['payment'] . " has been credited in your account";
$mail->AddAddress($receipientEmail);
$mail->Subject = $Subject;
$mail->Body = $Body;
Thanks
Your Host is incorrect . It should be:
$host = 'mail.gmail.com';
and the code is:
$mail = new PHPMailer();
$mail->IsHTML();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the server
$mail->Host = MailConfig::$Host; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = MailConfig::$Username; // GMAIL username
$mail->Password = MailConfig::$Password;
Note the SMTPSecure line