Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function mailTo($recipients)
- {
- $f3 = Base::instance();
- $edit = $f3->get('editTrue');
- $user = AclHelper::getCurrentUser();
- $template= new Template;
- if(isset($edit))
- {
- $mailBody = $template->render('leave/requestEdit.html');
- }
- else
- {
- $mailBody= $template->render('leave/emailTemp.html');
- }
- // When true, PHPMailer returns exceptions
- $mail = new PHPMailer(true);
- try {
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->isHTML(true);
- $mail->addAddress($user['email']);
- $mail->addAddress("malakar.rakesh1993@gmail.com");
- // foreach($recipients as $recipient){
- // $mail->addCC($recipient);
- // }
- $mail->SMTPAuth = true; // authentication enabled
- $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
- $mail->Host = "smtp.gmail.com";
- $mail->Port = 465; // or 587
- $mail->Username = "malakar.rakesh1993@gmail.com";
- $mail->Password = "abcd";
- // $mail->Host = $f3->get('GBD.smtp.host'); // Specify main and backup SMTP servers
- $mail->setFrom($user['email']);
- $userFullName = trim(ucfirst($user['firstname'])) . " " . trim(ucfirst($user['lastname']));
- $mail->FromName = $userFullName;
- $mail->Body = $f3->get('message');
- $mail->Body .="<br>". $mailBody;
- if(isset($edit))
- {
- $mail->AltBody = '';
- }
- else
- {
- $mail->AltBody = 'Hello Team,<br>I would like to request leave for the leave dates specified as follows.
- Application Date:' . $f3->get('issuedDate') . '<br>Leave requested from:' . $f3->get('leaveFrom') . '<br>Leave requested to:' . $f3->get('leaveTo') . '<br>Leave Description:' . $f3->get('leaveDescription') . 'Leave Type:' . $f3->get('leaveType').'<br><br>Hoping for a positive response.<br><br> Thank you.';
- }
- $mail->Subject = 'Updates on leave date applied';
- $mailStatus = (boolean)$mail->send();
- if ($mailStatus === true) {
- return $mail;
- }
- } catch (phpmailerException $e) {
- $response = array(
- 'status'=>'error',
- 'message'=>'Got some error while sending emails',
- 'exceptions'=>$e->getMessage()
- );
- return $response;
- } catch (Exception $e) {
- $response = array(
- 'status'=>'error',
- 'message'=>'Got some error while sending emails',
- 'exceptions'=>$e->getMessage()
- );
- return $response;
- }
- }
- This sender failed our fraud detection checks and may not be who they appear to be. Learn about spoofing
Add Comment
Please, Sign In to add comment