1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/ninja/mailers/Mailer.php

28 lines
841 B
PHP
Raw Normal View History

2013-12-25 22:34:42 +01:00
<?php namespace ninja\mailers;
2013-12-10 18:18:35 +01:00
use Mail;
use Utils;
2013-12-10 18:18:35 +01:00
2015-01-11 13:30:08 +01:00
class Mailer
{
public function sendTo($toEmail, $fromEmail, $fromName, $subject, $view, $data = [])
{
$views = [
'emails.'.$view.'_html',
'emails.'.$view.'_text',
];
2013-12-10 18:18:35 +01:00
2015-01-11 13:30:08 +01:00
Mail::send($views, $data, function ($message) use ($toEmail, $fromEmail, $fromName, $subject) {
$replyEmail = $fromEmail;
2014-11-19 20:51:53 +01:00
2015-01-11 13:30:08 +01:00
// http://stackoverflow.com/questions/2421234/gmail-appearing-to-ignore-reply-to
if (Utils::isNinja() && $toEmail != CONTACT_EMAIL) {
$fromEmail = NINJA_FROM_EMAIL;
}
2015-03-10 13:39:25 +01:00
//$message->setEncoder(\Swift_Encoding::get8BitEncoding());
2015-01-11 13:30:08 +01:00
$message->to($toEmail)->from($fromEmail, $fromName)->replyTo($replyEmail, $fromName)->subject($subject);
});
}
}