Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

Added mailers #34

Merged
merged 1 commit into from
Jul 19, 2013
Merged

Added mailers #34

merged 1 commit into from
Jul 19, 2013

Conversation

jeremyFreeAgent
Copy link
Contributor

Now you can configure several mailers.

@@ -50,25 +50,31 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$mailer = $this->getContainer()->get('mailer');
$transport = $mailer->getTransport();
if ($this->getContainer()->getParameter('swiftmailer.spool.enabled')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the command should send flush the spool for a single mailer instead of looping over all of them (with an argument or an option to select the mailer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With an optional argument ?

@stof
Copy link
Member

stof commented Apr 17, 2013

You should have 2 tests with the extended config formats: one with several mailers (the one you added here) and 1 with a single mailer IMO. It will show you that the XML config is wrong currently (parsing XML produces a different result for 1 or several childs, and using a bad XML structure does not allow the Config component to normalize it)

@stof
Copy link
Member

stof commented Apr 17, 2013

you also need to update the profiler integration to avoid mixing the different mailers together (it might require branching for 2.3 as the DataCollector is in the bridge)

$mailer['port'] = 'ssl' === $mailer['encryption'] ? 465 : 25;
}

foreach (array('encryption', 'port', 'host', 'username', 'password', 'auth_mode', 'timeout', 'source_ip') as $key) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be inside the if statement as it only applies to SMTP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll fix it.

@jeremyFreeAgent
Copy link
Contributor Author

I've added the test with a single mailer and the DataCollector.

@shouze
Copy link

shouze commented Apr 30, 2013

Nice job! 👍

@bmeynell
Copy link

bmeynell commented May 2, 2013

👍 Much needed

@jeremyFreeAgent
Copy link
Contributor Author

What to you think about it @stof ?

@shouze
Copy link

shouze commented May 3, 2013

Tested, looks ready 🔨

@bmeynell
Copy link

bmeynell commented May 3, 2013

@jeremyFreeAgent / @shouze - it says Travis is failing?

@jeremyFreeAgent
Copy link
Contributor Author

@bmeynell it's because of the Resources/config/schema/swiftmailer-1.0.xsd update and the

<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
                        http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">

in the tests XML files.

@shouze
Copy link

shouze commented May 3, 2013

@bmeynell : @jeremyFreeAgent can't upload the new xsd on symfony.com... so unless he puts a file:// scheme with the complete local filesystem path to the xsd it won't pass tests... and of course no way to do it.

This feature is non BC break and tests will pass when the new xsd will be online.
If you try locally on your computer with the file:// scheme trick you'll see it's okay 😉

@shouze
Copy link

shouze commented May 3, 2013

@bmeynell there's one solution : having a proxy that match & serve the local xsd during the tests instead of fetching the online (and maybe not up2date) one.

@stof what about implementing this solution ?

@bmeynell
Copy link

bmeynell commented May 3, 2013

Is this a configuration BC break? I seemed to had to define the mailers: node even for just one mailer. I also had to comment out my antiflood configuration or else an exception was thrown. Other than that, I'm successfully using two mailers now in my fork! :)

@bmeynell
Copy link

bmeynell commented May 3, 2013

Hmm.. CLI works but symfony doesn't load via the web:

ErrorException: Warning: Missing argument 2 for Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector::__construct(), called in app/cache/dev/appDevDebugProjectContainer.php on line 3348 and defined in src/vendor/symfony/src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php line 39

Thoughts?

@shouze
Copy link

shouze commented May 3, 2013

Yes there's also a PR on SwiftMailerBridge ;)

Le vendredi 3 mai 2013, Ben Meynell a écrit :

Hmm.. CLI works but symfony doesn't load via the web:

ErrorException: Warning: Missing argument 2 for Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector::__construct(), called in app/cache/dev/appDevDebugProjectContainer.php on line 3348 and defined in src/vendor/symfony/src/Symfony/Bridge/Swiftmailer/DataCollector/MessageDataCollector.php line 39

Thoughts?


Reply to this email directly or view it on GitHubhttps://github.com//pull/34#issuecomment-17416287
.

Cordialement,
Sébastien HOUZÉ

@jeremyFreeAgent
Copy link
Contributor Author

Yes, you should update the bridge too. @bmeynell can you write your config please? I will take a look. Thanky.

@bmeynell
Copy link

bmeynell commented May 6, 2013

Bridge updated! TY!

@jeremyFreeAgent - My config:

    mailers:                                                                       
        default:                                                                   
            encryption: ssl                                                        
            auth_mode:  login                                                      
            transport:  %mailer.transport%                                         
            host:       %mailer.host%                                              
            port:       %mailer.port%                                              
            username:   %mailer.user%                                              
            password:   %mailer.password%                                          
            antiflood:                                                             
                threshold:            100                                          
                sleep:                1                                            
        second:                                                                     
            encryption: ssl                                                        
            auth_mode:  login                                                      
            transport:  %mailer.transport%                                         
            host:       %mailer.host%                                              
            port:       %mailer.port%                                              
            username:   %second.mailer.user%                                        
            password:   %second.mailer.password%                                    
            antiflood:                                                             
                threshold:            100                                          
                sleep:                1

Error:

  [Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]  
  The service "swiftmailer.mailer.default.pl                                    
  ugin.antiflood" has a dependency on a non-                                    
  existent parameter "swiftmailer.mailer.def                                    
  ault.antiflood.threshold". 

@jeremyFreeAgent
Copy link
Contributor Author

@bmeynell Fixed, typo in the parameter name. Sorry.

@@ -35,6 +36,7 @@ protected function configure()
->addOption('message-limit', 0, InputOption::VALUE_OPTIONAL, 'The maximum number of messages to send.')
->addOption('time-limit', 0, InputOption::VALUE_OPTIONAL, 'The time limit for sending messages (in seconds).')
->addOption('recover-timeout', 0, InputOption::VALUE_OPTIONAL, 'The timeout for recovering messages that have taken too long to send (in seconds).')
->addArgument('mailer', InputArgument::OPTIONAL, 'The mailer name.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use an option rather than an optional argument ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the command help should be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sure.

@jeremyFreeAgent
Copy link
Contributor Author

+2

->setHelp(<<<EOF
The <info>%command.name%</info> displays the configured mailers:

<info>php %command.full_name%</info>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name argument should be documented.

@fabpot
Copy link
Member

fabpot commented Jun 13, 2013

Just to make sure: is this BC?

@stof
Copy link
Member

stof commented Jun 13, 2013

@fabpot the user-facing services are BC. The only BC break is in the data collector for the profiler, which is why it should be kept in sync with the symfony PR, and why I suggested to move the collector to the bundle as it is not generic anyway (it relies on the container)

@fabpot
Copy link
Member

fabpot commented Jun 13, 2013

ok, moving the data collector to the bundle is fine.

@jeremyFreeAgent
Copy link
Contributor Author

Done ;)

fabpot added a commit that referenced this pull request Jul 19, 2013
This PR was merged into the master branch.

Discussion
----------

Added mailers

Now you can configure several mailers.

Commits
-------

cf5de43 Added mailers
@fabpot fabpot merged commit cf5de43 into symfony:master Jul 19, 2013
@fabpot
Copy link
Member

fabpot commented Jul 19, 2013

Merged now. Thank you very much to everyone who was involved in this long-running PR (especially @jeremyFreeAgent for his patience).

Anyone willing to update the documentation for this feature?

@jeremyFreeAgent
Copy link
Contributor Author

Thanks @fabpot ! Can you give me a SensioLabsConnect "long PR badge" for that ? lol

fabpot added a commit that referenced this pull request Jul 23, 2013
This PR was squashed before being merged into the master branch (closes #42).

Discussion
----------

fix OutOfBoundsException when using mail or sendmail transport

Hi,

Since the #34 had been merged, an exception occured when using mail or sendmail transport :

```
[Symfony\Component\DependencyInjection\Exception\OutOfBoundsException]
  The index "1" is not in the range [0, 0].
```

This patch fix it.

Commits
-------

01fb626 fix OutOfBoundsException when using mail or sendmail transport
@Koc Koc mentioned this pull request Sep 2, 2013
egeloen pushed a commit to egeloen/symfony that referenced this pull request Nov 4, 2013
…or (PR symfony#8520)

This PR was merged into the master branch.

Discussion
----------

[SwiftmailerBridge] Marked MessageDataCollector as deprecated

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | yes
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Now you can configure several mailers.

Linked to the following PR:
- [ ] symfony/swiftmailer-bundle#34

Commits
-------

15bf1d7 [SwiftmailerBridge] Marked MessageDataCollector as deprecated
return;
}

$definition = $container->findDefinition('swiftmailer.transport');
foreach ($container->findTaggedServiceIds('swiftmailer.plugin') as $id => $args) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a BC break. ping @jeremyFreeAgent ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about registering swiftmailer.plugin services to each transport?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know swift mailer enough ...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't looking like a BC break at the time we did that. @lyrixx have you experienced any breakage?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wep, my plugin is not registered anymore. Anyway, I just updated the tag name ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.