-
-
Notifications
You must be signed in to change notification settings - Fork 152
Emails not sending from commands using memory spooling #127
Comments
I've done some more digging and have found that when using memory spooling, flushQueue() is called from vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php It is calling this when the command ends, so I definitely do not need the code to manually flush the queue. To see what was going on I edited the flushQueue() function and did a var_dump on the $transport variable. I see that it is using the null transport Swift_Transport_NullTransport to send the emails, which should only be used if disable_delivery is set on the config (or if the transport is set to null in the config) The problem appears to be coming from this line swiftmailer-bundle/EventListener/EmailSenderListener.php
I checked $name and it is "default" I only have one mailer setup in my config
which is pulling the values from parameters.yml
I also checked what I get from this line, in the same class
I've attached the debug dumps for the mailer and the transport that I am getting, but I'm not sure they help much: |
Im experiencing the same bug. The bug was introduced in v2.3.10, v2.3.9 works. So my guessing is, that it has something to do with #121. |
2.3.11 doesn't work either? |
After digging deeper i think i found the problem. In my case i had the following yml configs: parameters.yml parameters:
mailer_delivery_address: ~ config.yml imports:
- { resource: parameters.yml }
swiftmailer:
delivery_address: "%mailer_delivery_address%" So, Maybe that check should something like: return array_key_exists('delivery_address', $v) && '' === (string) $v['delivery_address']; That would include empty strings, |
We also have this issue with 2.3 and Symfony 2.7.4. Our temporary solution is not that great for now, but at least it works: Basically in a command this does not work:
This does:
|
That's really weird. |
Hi, The workaround given by @danieldumbrava is working :
instead of
|
Hi, We are haveing the same issue in our ExceptionController. Messages are not being set, while they are from normal controllers and even commands. When debugging I found our that the message is being queued via @danieldumbrava workaround works. Symfony v2.7.29, swiftMailer 5.4.8 and symfony/swiftmailer-bundle 2.6.2, with spool set to memory |
I experienced the same issue, the workaround works.
|
For people that have issues, do you have $kernel->terminate() in your front controller? I believe that’s where the message queues are fired. |
@weaverryan That's correct. If you're sending from a custom Plain-old-PHP-Script ( use Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener;
// ... boot Symfony and send your message
(new EmailSenderListener($container, $container->get('logger')))->onTerminate(); |
I am working on an old 2.0 installation and can't get email sending to work via a command. This is what I am doing:
I tried also the following but to no avail:
In the latter case, I get: Debugging the container shows I only have EDIT: The solution was to add the service: https://stackoverflow.com/a/21303631/1025495 |
I'm using Symfony 2.7.3 and Swiftmailer 5.4.1 and according to the documentation (and from PR #64) these versions should automatically handle emails when memory spooling is used.
Emails are sending okay in controllers, so the config is setup correctly.
I've tried sending with the standard email code
I also tried with the manual flush code at the end of the command
Neither of these worked. (I've also checked that $recipients and $message are valid)
The text was updated successfully, but these errors were encountered: