For smart Primates & ROBOTS (oh and ALIENS ).

Saturday, November 08, 2014

mail using PHPMailer

PROBLEM:
How to send using PHPMailer

SOLUTION:

PHPMailer is the good option to send email in PHP. To use PHPMailer first download it from
https://github.com/PHPMailer/PHPMailer

extract and paste entire folder. paste below code:

<?php
require_once('phpMailer/class.phpmailer.php');
public function sendEMail($tto, $fFrom, $sSubject, $bBody) {
$html_message = $bBody;
$mail = new PHPMailer();
                $mail->Host = 'mail.site.com';// set here your mail server
                // set user and pass of your email if authentication required.
                $mail->Username     = 'user';
                $mail->Password     = 'pass';
$mail->From = $fFrom;
$mail->FromName = "Test".' '."Mail"; //name
$mail->Subject = $sSubject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($html_message);
$mail->AddAddress($tto);
$mailAns = $mail->Send();
return $mailAns;
}
sendEMail("toemail", "fromemail", "subject", "email msg body")
?>
Share:

0 comments:

Post a Comment

Featured Post

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why?

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why? So, you can face this situation while...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive