By default, the symfony mail delivery strategy is set to none. That means, that calling send method upon sfMailer object will perform no action.
Configuring mail delivery_strategy
All possible delivery strategies are described in the symfony docs. A good solution is to edit factories.yml in all application config directories and set production environment to realtime and development environment to single_address. The developer enters an E-mail address he's got access to, puts it in the delivery_address option and all mails sent from the project will be delivered to that address (so there's no worry that a customer/user will receive test E-mail). Put the following lines into factories.yml file to define mail configuration:
prod: mailer: param: delivery_strategy: realtime dev: mailer: param: delivery_strategy: single_address delivery_address: your@address.comOnce we've set those values (even in the very beginning of a project development), we don't have to carry about mail configuration, hence symfony will carry out all mails to the correct addresses when working in the production environment.
Thanks for the tip. Previously I've used a worker class to send mail with a conditional statement based on a value in app.yml - but this makes much more sense
ReplyDeleteOf course there could me more configuration solutions, but IMHO above is sufficient in 99% cases.
ReplyDeleteThat's a nice one ! Thanks for the tip !
ReplyDelete