Download PHP-MAILER-MASTER lib files from the below link.
https://drive.google.com/open?id=1qQAEeo-twkKKh-_o8d-_2pwgop8IUJqE
code:
<?php
require_once('PHPMailer-master/PHPMailerAutoload.php');// include phpmailer class
echo sendEmail('destination@gmail.com','MESSAGE-HEADER','MESSAGE-BODY');
//sendEmail(Destination email,Heading of message,Message to send)
function sendEmail($email,$subject,$message)
{
$adminemail='SOURCE_NAME';
//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.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 = 'source@gmail.com';//from the email which you want to send(source email)
//Password to use for SMTP authentication
$mail->Password = 'sourcepassword';//password of source email
//Set who the message is to be sent from
$msg=$message;
$mail->Subject = $subject;
//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($msg);
//Replace the plain text body with one created manually
$mail->AltBody = 'Update';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
$res= " Failed To Send Email".$mail->ErrorInfo;
}
else {
$res= " Email(s) sent SuccessFully";
}
$response=$res;
return $response;
}//end of send mail
?>
->LOGIN WITH YOUR GMAIL ACCOUNT IN THE BROWSER.
->OPEN GOOGEL ACCOUNT.
->GO TO SECURITY TAB.
-> THEN ENABLE Access allowed for less secure apps
-> THEN SAVE THE ABOVE CODE AND CHANGE THE HIGHLIGHTED DETAILS AND RUN SAVED PAGE IN THE BROWSER.
0 Response to "SENDING MAIL IN PHP"
Post a Comment