php - symfony2 unable to send email via gmail -
i have been trying send email using swiftmailer, not able so, getting following exception
request.critical: uncaught php exception swift_transportexception: "failed authenticate on smtp server username "myusername@gmail.com" using 1 possible authenticators" @ /home/ubuntu/symfony/vendor/swiftmailer/swiftmailer/lib/classes/swift/transport/esmtp/authhandler.php line 184 [] []
can tell missing here? looks authentication failing reason.
here snippet config file:
swiftmailer: transport: gmail encryption: ssl auth_mode: login host: smtp.gmail.com username: myusername@gmail.com password: password
my dev server has ubuntu v13 os
try removing config_dev.php
encryption: ssl auth_mode: login
there no need specify encryption: , auth_mode: if you're using transport: gmail see symfony2.3 cookbook how use gmail send emails
quick , dirty way test email options. init new symfony 2.3 project , in default controller in acme /demobundle put action.
/** * @route("/mail") * @template() */ public function mailaction() { $message = \swift_message::newinstance() ->setsubject('hello email') ->setfrom('send@example.com') ->setto('mymail@example.com') ->setbody( $this->renderview( 'demobundle:default:email.txt.twig', array('name' => 'user1') ) ) ; $this->get('mailer')->send($message); return array('name' => 'whatever'); }
twig templates in acme/demo/bundle/resources/views/default frontend template
mail.html.twig
{% extends '::base.html.twig' %} {% block body %} mail template {% endblock %}
the mailer template. email.txt.twig
this test email {{name }}
going /mail should send email.
Comments
Post a Comment