I am not able to send email from any hosting containing link of my website https://www.gogglegator.com. Emails are working fine without this link and all other links in email are working fine.
When I tried phpmailer, I got error Mailer Error: SMTP Error: data not accepted.
Is there anybody who faced such issue ever and have possible troubleshooting steps? I am searching from three days but no success.
Thanks in advance for your time.
<?php
require_once('class.phpmailer.php');
include("class.smtp.php");
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
//Set the hostname of the mail server
$mail->Host = "smtp.mail.yahoo.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 465;
//Username to use for SMTP authentication
$mail->Username = "myaddress#yahoo.com";
//Password to use for SMTP authentication
$mail->Password = "mypass";
//Set who the message is to be sent from
$mail->setFrom('myaddress#yahoo.com', 'Test');
//Set an alternative reply-to address
$mail->addReplyTo('myaddress#yahoo.com', 'Test');
//Set who the message is to be sent to
$mail->addAddress('myaddress#yahoo.com');
//Set the subject line
$mail->Subject = "Test";
$mail->MsgHTML("https://www.gogglegator.com/");
if (!$mail->send()) {
$message = "Mailer Error: " . $mail->ErrorInfo;
} else {
$message = "Thank you for contacting us.";
}
echo $message; ?>
Related
I tried to send a mail using smtp server in php mailer function.
This was the error am getting when I triggered this.
Am using the gmail mail server.
SMTP connect() failed.
require_once(TEMPLATEPATH . '/PHPMailer-master/PHPMailerAutoload.php');
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "smtp.gmail.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "xxxx";
//Password to use for SMTP authentication
$mail->Password = "xxxx";
//Set who the message is to be sent from
$mail->setFrom('xxxx', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('xxxxx', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('xxxx', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
$mail->msgHTML('test');
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
This is my code. Please suggest what is the mistake in my code or where to check smtp connection failed error.
Thanks in Advance.
Well, that's why it didn't work ,
Open your php.ini and search for this line ;extension=php_openssl.dll and remove the semi colon before it , save the file and restart your webserver. You will see your coding working after you do this change.
and set your host as follow:
$mail->Host = "ssl://smtp.gmail.com";
i want to send email after user checkout from cart
my controller:
include('js/phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->Host = "ssl://smtp.gmail.com"; // SMTP server Gmail
$mail->Mailer = "smtp";
$mail->Port = 465;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPDebug = 1;
$mail->Username = "my gmail"; //
$mail->Password = "my pass"; // SMTP password
$webmaster_email = "my gmail"; //Reply to this email ID
$email = "recipient gmail"; // Recipients email ID
$name = "John"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Aryono King";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Goeboek I-Mut");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Subject Test";
$mail->Body = "Test Content"; //HTML Body
if(!$mail->Send()) {echo "Mailer Error: " . $mail->ErrorInfo;}
else {echo "<strong>Email Send</strong>";}
but it show error like this
2015-05-20 21:46:43 SMTP ERROR: Failed to connect to server: (0) 2015-05-20 21:46:43 SMTP connect() failed. Mailer Error: SMTP connect() failed.
what's the problem? i can't solve it, i search everywhere and i can't fint the answer, please someone help me
Take a look at the example here.
While personally, I do it like this:
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'ssl://smtp.googlemail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $email_mail; // SMTP username
$mail->Password = $email_pass; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
Try to check against yours, like for example: $mail->Host = 'ssl://smtp.googlemail.com';, which supposed to be don't have ssl://.
Two things you need to check before using phpmailer for gmail
need to check whether SMTP port and email + password is correct or not
You need to authenticate from your gmail account for sending email from unsecured sources, means: when first you send an email, google will send you an email asking your permission to allow to forward email from your id, here your required to click allow
One more thing, Port 587 is working perfectly for me, instead of 465
Hi,
there's more...I have seen that antivirus or firewall installed in your computer may block sending emails via localhost as it may considered as spam attacks
use this code...
include 'PHPMailerAutoload.php';
function send_mail($mail_to,$mail_to_fname,$mail_to_lname,$subject,$message)
{ $mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = 'mail.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = " YOUR GMAIL ";
$mail->Password = " YOUR GMAIL PASSWORD";
$mail->setFrom(' YOUR GMAIL ', ' YOUR NAME ');
$mail->addAddress($mail_to,$mail_to_fname . " " . $mail_to_lname);
$mail->Subject = $subject;
$mail->msgHTML($message);
$mail->AltBody = ' ';
if (!$mail->send()){echo "FALSE" . $mail->ErrorInfo;}
else{echo "TRUE";}
}
// How to user
// send_email(" email address where to send "," reciepient first name ","reciepient last name "," subject ", " message as html code ");
you need to do one more step for allowing gmail to send messages...!
(*) accept to allow google to send emails from unsecured apps, that link will be sent to your gmail, after you send first email
I recently setup phpmailer as my SMTP sending script to use for a website I've been working on and it's been nothing but a headache. My setup is IIS, and I'm currently using office365 to send out emails(although I have tried gmail and the results were no faster).I would appreciate any and all advice on how to speed this up, or if there's a way to post to a php file from javascript or php and then just let it work I could do that too. I'm trying to stay away from cron jobs if possible.
my script:
function sendMail($code, $email) {
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "smtp.office365.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 587;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "support#[domain redacted].com";
//Password to use for SMTP authentication
$mail->Password = "[password redacted]";
//enable TLS
$mail->SMTPSecure = 'tls';
//Set who the message is to be sent from
$mail->setFrom('support#[domain redacted].com', '[redacted]');
//Set an alternative reply-to address
$mail->addReplyTo('support#[domain redacted].com', '[redacted]');
//Set who the message is to be sent to
$mail->addAddress($email);
//Set the subject line
$mail->Subject = 'This is a test email from EdTester Support';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->Body = "Hello there, This is your activation e-mail. Please go to: http://[domain redacted]/activate.php?code=". $code . "&email=" . $email;
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
}
I am having this problem for my php mailer function. I tried changing the required file but still its the same. Can anyone help me with this error.
This is my phpmailer code:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->IsHTML(true);
$mail->Username = "testnoreply#gmail.com";
$mail->Password = "test";
$mail->SetFrom("testnoreply#gmail.com");
$mail->Subject = "Membership expire notice";
$mail->Body = "Dear ICONIS member your membership is going to expire please renew it";
$mail->AddAddress($em);
if (!$mail->Send()) {
echo "Mailer Error: " .$mail->ErrorInfo;
} else {
echo "Mail has been sent";
}
Are you sure you have both the class.phpmailer.php AND the class.smtp.php in your folder?
Try including class.smtp.php before including class.phpmailer.php, as the following:
<?php
include 'class.smtp.php';
include 'class.phpmailer.php';
// your code goes here
Then tell if you got some error.
just download all files, extract the files into a folder and include PHPMailerAutoload.php from the folder.
<?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
/*======================================*/
/*======================================*/
require 'YOURFOLDERNAME/PHPMailerAutoload.php';
/*======================================*/
/*======================================*/
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "username#gmail.com";
//Password to use for SMTP authentication
$mail->Password = "yourpassword";
//Set who the message is to be sent from
$mail->setFrom('from#example.com', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('replyto#example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('whoto#example.com', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
try
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
instead of
require 'class.phpmailer.class.php';
$mail = new PHPMailer;
can someone help me to find what is wrong with the following code that i used to send mail in php.
error_reporting(E_STRICT);
date_default_timezone_set('asia/kolkata');
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->IsHTML(true);
$mail->Username = "manikandan#gmail.com";
$mail->Password = "mypassword";
$mail->From = ("manikandan#gmail.com");
$mail->SetFrom("manikandan");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("peter1991#gmail.com");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
i am getting the following error:- 2015-01-05 04:32:10 Invalid address: manikandan
i am using php 5.2.2 ,Apache 2.0 Handler in windows.
setFrom expects an email address as the first parameter. Try:
$mail->setFrom('manikandan#gmail.com');
If you also want to set a proper name, use the second parameter
$mail->setFrom('manikandan#gmail.com', 'John Smith');
http://phpmailer.github.io/PHPMailer/classes/PHPMailer.html#method_setFrom
Also, I think you should be using the autoloader instead of including the PHPMailer class directly.
try this:
$mail->setFrom('manikandan#gmail.com', 'manikandan'); //setFrom expect email
Full code:
<?php require 'PHPmailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->IsSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 465;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'ssl';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "manikandan#gmail.com";
//Password to use for SMTP authentication
$mail->Password = "mypassword";
//Set who the message is to be sent from
$mail->setFrom('manikandan#gmail.com', 'manikandan');
//Set an alternative reply-to address
$mail->addReplyTo('peter1991#gmail.com', 'peter');
//Set who the message is to be sent to
$mail->addAddress('peter1991#gmail.com', 'peter1991');
//Set the subject line
$mail->Subject = 'Test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->Body = "Hi ,! Welcome to PHP mail function. \n\n .";
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.gif');
$mail->SMTPAuth = true;
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
To resolved this just turn on access for less secure app in your google account. Hope this helps.