Solved-mail not send with phpmailer
if you face problem to send mail from your localhost or live server you can use this code to solve your problem.
function SendMail( $ToEmail,$subjectval, $MessageHTML, $MessageTEXT ) {
// require_once ( 'class.phpmailer.php' ); // Add the path as appropriate
include_once "webroot/phpmailer/PHPMailerAutoload.php";
$Mail = new PHPMailer();
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server
$Mail->SMTPDebug = 0; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "tls"; //Secure conection
$Mail->Port = 587; // set the SMTP port
$Mail->Username = 'yourmailaddress@gmail.com'; // SMTP account username
$Mail->Password = 'yourpassword'; // SMTP account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = $subjectval;
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'info@grabthings.com';
$Mail->FromName = 'Grabthings';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line
$Mail->AddAddress( $ToEmail ); // To:
$Mail->isHTML( TRUE );
$Mail->Body = $MessageHTML;
$Mail->AltBody = $MessageTEXT;
$Mail->Send();
$Mail->SmtpClose();
// if ( $Mail->IsError() ) { // ADDED - This error checking was missing
//return FALSE;
// }
// else {
return TRUE;
// }
}after using this function you can send mail from localhost or live server.
for how to send mail from localhost using phpmailer tutorial please click here.http://thecoderain.blogspot.in/2016/05/send-mail-using-phpmailer-from-localhost-and-live-server.html
// require_once ( 'class.phpmailer.php' ); // Add the path as appropriate
include_once "webroot/phpmailer/PHPMailerAutoload.php";
$Mail = new PHPMailer();
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server
$Mail->SMTPDebug = 0; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "tls"; //Secure conection
$Mail->Port = 587; // set the SMTP port
$Mail->Username = 'yourmailaddress@gmail.com'; // SMTP account username
$Mail->Password = 'yourpassword'; // SMTP account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = $subjectval;
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'info@grabthings.com';
$Mail->FromName = 'Grabthings';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line
$Mail->AddAddress( $ToEmail ); // To:
$Mail->isHTML( TRUE );
$Mail->Body = $MessageHTML;
$Mail->AltBody = $MessageTEXT;
$Mail->Send();
$Mail->SmtpClose();
// if ( $Mail->IsError() ) { // ADDED - This error checking was missing
//return FALSE;
// }
// else {
return TRUE;
// }
}after using this function you can send mail from localhost or live server.
for how to send mail from localhost using phpmailer tutorial please click here.http://thecoderain.blogspot.in/2016/05/send-mail-using-phpmailer-from-localhost-and-live-server.html
Comments
Post a Comment