1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/app/Services/EmailService.php

48 lines
1.0 KiB
PHP
Raw Normal View History

2015-10-11 16:41:09 +02:00
<?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;
}
}