Symfony FOSUserBundle E-Mail Confirmation - php

I just installed the FOSUserbundle and I want to have the e-mail confirmation enabled. Meaning if someone registers the user should get an email with an activation link.
I always get the following message:
FatalErrorException: Error: Maximum execution time of 30 seconds exceeded in \app\cache\dev\classes.php line 420
Here is the config.yml file:
#FOS User Bundle
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Dbe\DdddBundle\Entity\User
from_email:
address: info#dddd.ch
sender_name: Donaci
registration:
confirmation:
enabled: true # change to true for required email confirmation
What might be the problem? The error occures on the app_dev.php/register/check-email page.
Thanks in advance for your help!
EDIT: The problem exists with other functions like resetting too. I guess the problem is with the email? where and how exactly do i link it? i'm using swift mailer.
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
port: "587"
spool: { type: memory }

if you work on localhost try to change the transport setting to gmail and set the username and password to the Google credential
# app/config/config_dev.yml
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
spool: { type: memory }
encryption: ssl
auth_mode: login
host: smtp.gmail.com
username: yourEmail#gmail.com
password: password_gmail

Related

Symfony 1.4 sfMailer: Configure TLS self-signed

It seems that we need to configure the mailer to use self-signed certificates in a Symfony 1.4 project and no idea where to look at
Configuration right now:
mailer:
class: sfMailer
param:
delivery_strategy: realtime
delivery_address: user#mail.com
transport:
class: Swift_SmtpTransport
param:
host: x.x.x.x
port: 25
encryption: ~
username: user#mail.com
password: pass
I was looking at this question: PHP - Swiftmailer using STARTTLS and self signed certificates
But all examples are with Laravel and it seems very new so I'm not sure if Symfony 1.4 has all these features included.
I also looked at the mailer configuration but I didn't find anything of help there.
Any help on how to configure this without touching anything from vendor folder?
EDIT:
So this is the new configuration:
mailer:
class: sfMailer
param:
delivery_strategy: realtime
delivery_address: user#mail.com
transport:
class: Swift_SmtpTransport
param:
host: x.x.x.x
port: 25
encryption: ~
username: user#mail.com
password: pass
streamOptions:
ssl:
allow_self_signed: true
verify_peer: false
local_cert: "/etc/ssl/certificate.cer"
local_pk: "/etc/ssl/certificate.key"
Yes, you should be able to add these stream options options to the param section of the transport. If I read the class sfMailer right, it should look something like this:
transport:
class: Swift_SmtpTransport
param:
host: x.x.x.x
port: 25
encryption: ~
username: user#mail.com
password: pass
streamOptions:
ssl:
allow_self_signed: true
verify_peer: false

Cannot email via gmail

Unable to send mail via gmail in Symfony 2.8.3 in prod on freebsd host while it works on Windows 10 with same source code in both prod & dev. [Also unable to get a log of mailing on host, which might help resolve this.]
Update: Mail can be sent using PHP's mail() function. Using Swiftmailer to send mail from a controller does not work. Changed parameters to use mailer_transport: smtp mailer_host: localhost does not enable Swiftmailer to send from a controller.
parameters.yml:
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: {valid address}
mailer_password: (valid password}
config.yml:
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
encryption: ssl
auth_mode: login
config_prod.yml:
monolog:
handlers:
mail:
type: fingers_crossed
action_level: critical
handler: buffered
buffered:
type: buffer
handler: swift
swift:
type: swift_mailer
from_email: "%mailer_user%"
to_email: "%mailer_user%"
subject: Error report!
level: debug
In the absence of any other solution or finding a way to log Swiftmailer behavior I added a custom exception listener to send mail locally.

not recieving a confirmation email with fosuserbundle

i'm trying to do my first symfony project and i am using the fosuserbundle. It's working perfectly i'm just having a problem with the email confirmation, i'm not receiving anything.
This is my parameters.yml:
parameters:
database_host: 127.0.0.1
database_port: null
database_name: mydatabase
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: mymail#gmail.com
mailer_password: mypass
secret: 8c73d1f9bc7f50ce500d4a98a4627ffaa42dc905
this is myconfig.yml:
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
port: "585"
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: OC\UserBundle\Entity\User
service:
mailer: fos_user.mailer.twig_swift
registration:
confirmation:
enabled: true
from_email:
address: mymail#gmail.com
sender_name: myname
service:
mailer: fos_user.mailer.twig_swift
please can you help? because i searched on the web and tried but since it's my first project none of the solutions are working with me.
Try with these slight changes in your config.yml:
port: 585
auth_mod: login
The value for the port doesn't need to be enclosed in quotes. I'm not sure if this really makes a difference, but you should follow the conventions.
Since you're using smtp as mailer_transport you have also to specify the authentication mode. Check the documentation for more details:
http://symfony.com/doc/current/reference/configuration/swiftmailer.html
Eventually you'll need another value for the authentication mode.
EDIT (2016-02-19):
Instead of using smtp as mailer_transport you can use the shortcut gmail. Please see this article from the Symfony Cookbook:
http://symfony.com/doc/current/cookbook/email/gmail.html
Then you can omit the line:
auth_mod: login
This shortcut will set the host to smtp.gmail.com. In your configuration you have the host set to 127.0.0.1. This could eventually be the reason why it works with the web_profiler, but not with the real e-mail address.

Setting default_mailer for Swiftmailer in Symfony2 not working

I'm using Symfony 2.7 which comes with SwiftmailerBundle 2.3.8.
This is my configuration
swiftmailer:
mailers:
spool_mailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool:
type: file
path: %kernel.root_dir%/spool
instant_mailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
default_mailer: spool_mailer
I want to use 2 mailers, one for spooling and one for sending them instantly.
These two commands will work just fine, the email is either spooled or sent instantly.
$this->get('swiftmailer.mailer.instant_mailer')->send($email);
$this->get('swiftmailer.mailer.spool_mailer')->send($email);
However,
$this->get('mailer')->send($email);
Doesn't fetch the default_mailer which is the spooler in my case, but it sends it instantly. I've seen here that this is possible, but maybe that answer is incorrect.
Did I miss something in the configuration file? Or am I not calling it right?
I run into the same problem, even though using symfony version 2.6.8.
The only solution I found at this moment is: remove the default_mailer parameter, and set the default mailer with such name, this is: default.
So your configuration would be like:
swiftmailer:
mailers:
default: # your named spool_mailer
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool:
type: file
path: %kernel.root_dir%/spool
instant_mailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
From now the object gotten from $this->getContainer()->get('swiftmailer.mailer'); will be the one defined as default and NO more errors like this will be shown:
[Swift_TransportException]
Connection could not be established with host localhost [Connection refused #111]
This configuration worked for me in the project I am currently working on.
I hope it helps.

[Symfony2][SwiftMailer] You have requested a non-existent parameter "sender_name"

I installed a new bundle to my project in symfony2 and now swiftmailer returns an error.
You have requested a non-existent parameter "sender_name".
Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
encryption: %mailer_encryption%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
Try to add a sender_name parameter in your parameters.yml
and in your config.yml add
swiftmailer:
sender_name: %sender_name%

Categories