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")
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")
?>
0 comments:
Post a Comment