Skip to content

[0.3] Overwrite From Emails #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 0.3
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/Providers/MailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Canvas\Providers;

use Phalcon\Di\ServiceProviderInterface;
use Phalcon\Di\DiInterface;
use Baka\Mail\Manager as BakaMail;
use Phalcon\Di\DiInterface;
use Phalcon\Di\ServiceProviderInterface;

class MailProvider implements ServiceProviderInterface
{
Expand All @@ -14,11 +14,22 @@ class MailProvider implements ServiceProviderInterface
public function register(DiInterface $container) : void
{
$config = $container->getShared('config');
$app = $container->getShared('app');

$container->setShared(
'mail',
function () use ($config) {
$mailer = new BakaMail($config->email->toArray());
function () use ($config, $app) {
$emailConfig = $config->email->toArray();

if ($fromEmail = $app->get('email_from_email')) {
$emailConfig['from']['email'] = $fromEmail;
}

if ($fromName = $app->get('email_from_name')) {
$emailConfig['from']['name'] = $fromName;
}

$mailer = new BakaMail($emailConfig);
return $mailer->createMessage();
}
);
Expand Down