Skip to content
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

[Mailer] add File transport #31947

Open
wants to merge 4 commits into
base: 4.4
from

Conversation

Projects
None yet
6 participants
@Kocal
Copy link
Contributor

commented Jun 8, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #31819
License MIT
Doc PR symfony/symfony-docs#11702

This PR add the file transport to the Mailer component which is useful when running integrations tests.

I've taken this idea from SwiftMailer, but without the spool behavior. It just saves messages to the filesystem and nothing else.

It's supposed to be used like this:

# .env.test
MAILER_URL=file://%kernel.project_dir%/var/emails

Sent message will now be saved in the directory %kernel.project_dir%/var/emails, in a .message file.

What do you think about it?
Thanks!

@Kocal Kocal force-pushed the Kocal:feat/mailer-file-transport branch from c8c63a1 to fa1b684 Jun 8, 2019

@Kocal

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2019

Hum, I'm not sure how to make it working on Windows since file://C:\Users\appveyor\AppData\Local\Temp\1/symfony/emails is not a valid DNS. 😕

Any ideas?

@nicolas-grekas nicolas-grekas added this to the next milestone Jun 8, 2019

*
* @author Fabien Potencier <fabien@symfony.com>
*
* @experimental in 4.3

This comment has been minimized.

Copy link
@noniagriconomie

This comment has been minimized.

Copy link
@Kocal

Kocal Jun 8, 2019

Author Contributor

Hum, it depends if the Mailer component will still be experimental in 4.4 or not.
I will remove this line if it's not the case. 👍

Show resolved Hide resolved src/Symfony/Component/Mailer/Transport/FileTransport.php Outdated

Kocal added some commits Jun 8, 2019

@Kocal Kocal force-pushed the Kocal:feat/mailer-file-transport branch from 3b37a74 to 020fe16 Jun 12, 2019

$file = $this->path.'/'.uniqid().'.message';
$serializedMessage = serialize($message);
if (false === file_put_contents($file, $serializedMessage)) {

This comment has been minimized.

Copy link
@OskarStark

OskarStark Jun 12, 2019

Contributor

Why not using Filesystem here too?

This comment has been minimized.

Copy link
@Kocal

Kocal Jun 12, 2019

Author Contributor

I didn't want to make Mailer depends of Filesystem, but sure I can use it 👍

This comment has been minimized.

Copy link
@OskarStark

OskarStark Jun 12, 2019

Contributor

Not sure what others think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.