confirmation email not sent after registration in FOSUserBundle - symfony

My project is based on symfony 2.3.19 + lastest version version FOSUserBundle.
Actually, FOSuserBundle is working perfectly. In fact, all functionnalities are working correctly. Now, my goal is to activate the email confirmation when a user registers. For that, I configured my project in this way:
# app/config.yml
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: Minn\UserBundle\Entity\User
registration:
form:
type: minn_user_registration
confirmation:
enabled: true
template: MinnUserBundle:Registration:email.txt.twig
from_email:
address: XXXXXXX#gmail.com
sender_name: XXXXXXX
service:
mailer: fos_user.mailer.twig_swift
Checking this configuration, I get forwarded to /register/check-email with the message I wrote in MinnUserBundle:Registration:email.txt.twig. But no email was sent & no error was returned by symfony.
It there any idea?
Thanks,

It was just an error on SMTP credentials.... Thanks again....

Related

Password resetting > request redirects to login

config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Portal\UserBundle\Entity\User
registration:
confirmation:
enabled: true
form:
type: Portal\UserBundle\Form\RegistrationType
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
When I click on the password reset button, I am forwarded to the login. Button's Route:
{{ 'resetting.reset.submit'|trans }}
It looks like a bug - I have no special configuration, only this. FOSUserBundle version is v2.1.2.
your route "fos_user_resetting_request" must be able to visit anonymously, check that you do not have any security clause in this route [[example #security("has_role('any')") ]], remember to have this route in a firewall that allows anonymous visits
like:
firewalls:
database_security:
anonymous: ~
pattern: ^/

Resetting password not working symfony 3

I use FOSUserBundle on my symfony 3 project. Evrything is ok but i have ONE problem!!!:-(
when i try reset a password on "I forgot my password", no email sending...Even if, the application redirect user to resetting/check-email view.
Actually i test this on a local server with wamp.
This my configuartion files:
#app/paramaters.yml#
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: adress#gmail.com
mailer_password: ********
#app/config.yml#
# Swiftmailer Configuration
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
#FriendsOfSymfonyBundle Configuration
fos_user:
db_driver: orm
firewall_name: main
user_class: MA\UserBundle\Entity\User
from_email:
address: adress#gmail.com
sender_name: Admin
service:
mailer: fos_user.mailer.twig_swift
registration:
confirmation:
from_email:
address: adress#gmail.com
sender_name: Admin
resetting:
email:
from_email:
address: adress#gmail.com
sender_name: Admin
Somebody can help me??please!!
I had solve it changing the mailing transport on parameters.yml to "mail"
mailer_transport: mail

i cant send email symfony3 neither to confirm registration or for a simple email

Im developping a web application using symfony3 , i'm trying to send confirmation emails using swiftmailer , i want to use confirmation mails and resetting also send direct emails between the users of my app.
Unfortunately i didn't managed to do it yet.
Here is my configs files also the code that i use to send direct mails
Here is my parameter.yml
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_auth_mode: login
mailer_user: ***********
mailer_password: ********
mailer_encryption: ssl
Here is my code config.yml
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
encryption: ssl
username: '%mailer_user%'
auth_mode: login
password: '%mailer_password%'
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
registration:
confirmation:
enabled: true
from_email:
address: *****e#gmail.com
sender_name: ........
from_email:
address: ******#gmail.com
sender_name: ......
my code to send email
$mailer = $this->get('mailer');
$message = $mailer->createMessage()
->setSubject("Objet")
->setFrom(array('................' => "...."))
->setTo('..........)
->setBody("Hi");
$mailer->send($message);
Here is my parameters file:
mailer_transport: gmail
mailer_host: gmail
mailer_user: ************
mailer_password: **********
And here is my config file section for swiftmailer:
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I use dual verification in Gmail so I generated a application specific password,
this is where you can see how to set one.
This is how I send emails from my controller:
private function sendConfirmationEmail($user)
{
$token = $user->getEmailConfirmationToken();
$subject = 'Email Confirmation';
$label = 'Confirm Email';
$email = $user->getEmail();
$href = "www.mysymfonyproject.com/app_dev.php/confirm?token=" . $token;
$message = \Swift_Message::newInstance()
->setSubject($subject)
->setFrom('myemail#gmail.com')
->setTo( $email )
->setBody(
$this->renderView(
'Emails/confirm.html.twig',
array('href' => $href)
),
'text/html'
);
$this->get('mailer')->send($message);
return true;
}
Also, I see something slightly odd in your config file, it seems you set your "auth_mode" and "encryption" twice both in your parameters.yml and your config.yml.
Your config.yml file includes your parameters.yml file which is like your parameters.yml get copy-pasted to the config file and in the config file you have mailer settings where some values are pointers to pre set values and other are just values, %mailer_password% points to mailer_password parameter value which gets included from the parameters file. It's nothing complicated it's just YML and inclusion. Since you already defined all parameters in the parameters.yml all you need to do in config.yml is to point to them and you can do so by changing your config.yml section for mailer to look like this:
transport: "%mailer_transport%"
host: "%mailer_host%"
encryption: "%mailer_encryption%"
username: "%mailer_user%"
auth_mode: "%mailer_auth_mode%"
password: "%mailer_password%"
spool: { type: memory }
Or just copy my application settings and give it a try. A YML developers greeting "Good Luck :)"
PS. YML has to have proper indentation and the suggested edit of your config file is probably not indented correctly so indent it manually.

swiftmailer does not send emails

I want to send emails using symfony, but the swiftmailer does not send out any emails. I even dont get error reportings or anything else. Thats my code:
$mail = \Swift_Message::newInstance()
->setSubject('Subject')
->setTo('test#example.com') #this is replaced by real email of course
->setFrom('test#example.com')
->setBody('Testbody');
$this->get('mailer')->send($mail);
Thats the config:
swiftmailer:
default_mailer: mailer
mailers:
mailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
#spool: { type: memory }
I even tried to set the host to an address that does not exist, but I dont get any error from swiftmailer or symfony.
I tried to find the files for the lib, but there is no Swift_Message or newInstance anywhere in the symfony files, strange
use this code
$message = \Swift_Message::newInstance()
->setSubject('Validation de votre commande')
->setFrom('test#example.com')
->setTo('test#example.com')
->setBody('Testbody');
->setCharset('utf-8')
->setContentType('text/html')
->setBody('test');
$this->get('mailer')->send($message);
in app/config/parametres.yml :
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: your mail
mailer_password: your password mail
in app/config/config.yml :
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I had seen someone with the same problem. For him the problem was with the spool queue. It is solved by either disabling spool explicitly:
spool:
enabled:false
or flushing the queue in the code:
$this->get('mailer')->send($mail);
$spool = $this->get('mailer')->getTransport()->getSpool();
$spool->flushQueue($this->get('mailer')->getTransport());
Hope it works!

Sendmail and SwiftMailerBundle on Symfony2

Hello I am using Symfony2 and the SwiftMailerBundle, when i was using gmail like my transport, was so easy, but now i need use sendmail.
Here is the part of my parameters.yml
mailer_transport: sendmail
mailer_host: /usr/sbin/sendmail
mailer_user: no-replay#mysite.com
mailer_password: null
And here is the config.yml:
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
// Create the Transport
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs');
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
as per the documentation :
http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport
you need to create a Swift_SendmailTransport first then instantiate your mailer with it.
This question may help : Configure Symfony2/Swiftmailer to use "sendmail -t"

Resources