Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once ($_SERVER["DOCUMENT_ROOT"] . '/config.php');
- require_once ($_SERVER["DOCUMENT_ROOT"] . '/lib/phpmailer/PHPMailerAutoload.php');
- require_once ($_SERVER['DOCUMENT_ROOT'] . '/assets/messaging/email-template.php'); // This is where the templates stored
- class Email {
- public function sendEmail ($send_to_email, $sent_to_name, $template_name) {
- // this variables stored in config.php
- global $mandrill_host;
- global $mandrill_port;
- global $mandrill_username;
- global $mandrill_password;
- global $mandrill_from;
- global $mandrill_from_name;
- $mail = new PHPMailer;
- $mail->IsSMTP();
- $mail->Host = $mandrill_host;
- $mail->Port = $mandrill_port;
- $mail->SMTPAuth = true;
- $mail->Username = $mandrill_username;
- $mail->Password = $mandrill_password;
- $mail->SMTPSecure = 'tls';
- $mail->From = $mandrill_from;
- $mail->FromName = $mandrill_from_name;
- $mail->AddAddress($send_to_email, $sent_to_name);
- $mail->IsHTML(true);
- // I will have CASE here to select $subject, $body and $body_txt
- // from /assets/messaging/email-template.php
- // based on $template_name parameter
- $mail->Subject = $subject;
- $mail->Body = $body;
- $mail->AltBody = $body_txt;
- if(!$mail->Send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- exit;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement