2013-12-25 22:34:42 +01:00
|
|
|
<?php namespace ninja\mailers;
|
2013-12-10 18:18:35 +01:00
|
|
|
|
|
|
|
use Mail;
|
2014-09-12 14:11:59 +02:00
|
|
|
use Utils;
|
2013-12-10 18:18:35 +01:00
|
|
|
|
2014-03-05 21:19:12 +01:00
|
|
|
class Mailer {
|
2013-12-10 18:18:35 +01:00
|
|
|
|
2014-03-27 13:25:31 +01:00
|
|
|
public function sendTo($toEmail, $fromEmail, $fromName, $subject, $view, $data = [])
|
2013-12-10 18:18:35 +01:00
|
|
|
{
|
|
|
|
$views = [
|
2014-01-08 00:59:06 +01:00
|
|
|
'emails.'.$view.'_html',
|
|
|
|
'emails.'.$view.'_text'
|
2013-12-10 18:18:35 +01:00
|
|
|
];
|
2014-04-12 20:55:40 +02:00
|
|
|
|
|
|
|
Mail::send($views, $data, function($message) use ($toEmail, $fromEmail, $fromName, $subject)
|
2014-09-12 14:11:59 +02:00
|
|
|
{
|
|
|
|
$replyEmail = $fromEmail;
|
|
|
|
|
|
|
|
// We're unable to set the true fromEmail for emails sent from Yahoo or AOL accounts
|
|
|
|
// http://blog.mandrill.com/yahoos-recent-dmarc-changes-and-how-that-impacts-senders.html
|
|
|
|
if (strpos($fromEmail, '@yahoo.') !== false || strpos($fromEmail, '@aol.') !== FALSE)
|
|
|
|
{
|
|
|
|
$fromEmail = CONTACT_EMAIL;
|
|
|
|
}
|
|
|
|
|
2014-03-27 13:25:31 +01:00
|
|
|
$message->to($toEmail)->from($fromEmail, $fromName)->sender($fromEmail, $fromName)
|
2014-09-12 14:11:59 +02:00
|
|
|
->replyTo($replyEmail, $fromName)->subject($subject);
|
2014-01-08 00:59:06 +01:00
|
|
|
});
|
2013-12-10 18:18:35 +01:00
|
|
|
}
|
|
|
|
}
|