1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Services/EmailService.php
2015-10-11 17:41:09 +03:00

48 lines
1.0 KiB
PHP

<?php namespace App\Services;
use Carbon;
use App\Models\Invitation;
use App\Ninja\Mailers\UserMailer;
class EmailService {
protected $userMailer;
public function __construct(UserMailer $userMailer)
{
$this->userMailer = $userMailer;
}
public function markOpened($messageId)
{
$invitation = Invitation::whereMessageId($messageId)
->first();
if (!$invitation) {
return false;
}
$invitation->opened_date = Carbon::now()->toDateTimeString();
$invitation->save();
return true;
}
public function markBounced($messageId, $error)
{
$invitation = Invitation::with('user', 'invoice', 'contact')
->whereMessageId($messageId)
->first();
if (!$invitation) {
return false;
}
$invitation->email_error = $error;
$invitation->save();
$this->userMailer->sendEmailBounced($invitation);
return true;
}
}