swiftmailer works in dev, error in prod - symfony

I'm using swiftmailer to send my mails on my web app. It works perfectly fine on dev, but when I try in prod, I get this message :
Swift_TransportException: Failed to authenticate on SMTP server with username "[mymail]#gmail.com" using 1 possible authenticators
Any idea why ? I tried to cache:clear , checked mail and PW

Did you set all parameters like below in app/config/parameters.yml?
mailer_transport:
mailer_encryption:
mailer_auth_mode:
mailer_host:
mailer_user:
mailer_password:
I use gmail and i had to set the parameters like this:
mailer_transport: gmail
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: *****#gmail.com
mailer_password: ******

Related

How can I send emails using Symfony, Swift Mailer, and Office 365?

I'm using Symfony 3.4 deployed in HostGator. I need send emails to my users in some cases. If I use Gmail, the emails are sent without problem, but when I use Office 365, I'm getting the following error:
Connection could not be established with host
This is my email configuration:
parameters:
mailer_transport: smtp
mailer_host: ''
mailer_user: example#mydomain.co
mailer_password: 'mypassword'
mailer_port: '587'
mailer_smtp: 'smtp.office365.com'
I would try pasting the 'smtp.office365.com' for the field: mailer_host
Use host instead of mailer_smtp. I have this configuration for my swiftmailer. Hope it works for you.
# Swiftmailer Configuration
swiftmailer:
transport: 'smtp'
host: '%mailer_host%' // in your case : 'smtp.office365.com'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }

Symfony\Component\Yaml\Exception\ParseException

I am trying to update composer to integrate some other api, but cli shows the error
Indentation problem at line 13 (near " mailer_transport: smtp"). I do not know how to manage Yaml.
# This file is auto-generated during the composer install
parameters:
database_host:127.0.0.1
database_port:3306
database_name:news_driver
database_user:root
database_password: ''
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret:ThisTokenIsNotSoSecretChangeIt
twitter_consumer_key:<hidden>
twitter_consumer_secret:<hidden>
It's probably an indentation problem and you also miss a space between colons and values. I just tried to edit it in the YAML online parser here: http://yaml-online-parser.appspot.com/
Working version:
parameters:
database_host: 127.0.0.1
database_port: 3306
database_name: news_driver
database_user: root
database_password: ~
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: ThisTokenIsNotSoSecretChangeIt
twitter_consumer_key: NN51z30h469bKUJUQHesZg6CQ
twitter_consumer_secret: qKobQPtChifrD2LxnJI512EMGHqBGmnaJ9EQI7fL9wrrXwPY8f
Try to copy it from here, it should work now.

"Connection could not be established with host smtp.gmail.com". Symfony. Swiftmailer

I got exception:
Connection could not be established with host smtp.gmail.com
Same exception in old project Symfony2.8 and newest Symfony3.
I can ping smtp.gmail.com.
The Avast Antivirus was guilty.
In Google "Account settings" enable "Access for less secured apps" by setting it to "Allow".
Mailer host is your localhost or 127.0.0.1. It's not smtp.google.com
I'm using this configuration for my localhost application
parameters:
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: youremail#gmail.com //replace by your gmail account
mailer_password: ********** //replace by your gmail password
config.yml:
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
your controller code seems to be the same as mine.
As napestershine said in his response do not forget to allow less secure app on your gmail account.

Access denied for user 'root'#'localhost

I have an problem width production in my page web I imported my project in my server and I done my cache in active access but my site is inactive my error is
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost'
(using password: NO)' in
/home/sbstn/public_html/convention/CoCoSecto/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
my parameter to connection :
parameters:
database_host: Localhost
database_port: null
database_name: sbctn_convention
database_user: sbctn
database_password:**********
mailer_transport: smtp
mailer_host: localhost
mailer_user: null
mailer_password: null
secret: bde5720b4958a77108513d0e7ffe4662e8ad00f3
Please suggest me for better solution .
2 things to do:
Check your database parameters defined in app/config_prod.yml
Clear your production cache: php app/console cache:clear --env=prod

Cannot create database connection for Doctrine2 in Symfony2 with MAMP (Connection refused)

I'm in the process of learning Symfony2 for a project that me and some friends are taking on, and am taking a tutorial where you make a blog in Symfony2: http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html
Problem
I can't seem to get Doctrine2 to work. I give the following instruction to the Terminal:
php app/console doctrine:database:create
And get the following error message:
Could not create database for connection named symfony
SQLSTATE[HY000] [2002] Connection refused
System info
I have a mac that runs Mountain lion and I use MAMP.
What I have done
I went to the config page (http://localhost/NameOfProject/web/config.php) and went to the place where you configure your database. There I put in the path, port, user, password, etc from the MAMP start page.
What I have tried
A blog I came across suggested to create a symbolic link to the the MAMP mysql socket with the following command:
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock
This did not make the error go away for me.
Some of my files in symfony (if they are relevant)
From app/config/config.yml:
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: '8889'
database_name: symfony
database_user: root
database_password: root
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: 0408312e2b9861c0c86dbb7488aceec4296054ec
database_path: /Applications/MAMP/tmp/mysql/mysql.sock
From app/config/parameters.yml:
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: '8889'
database_name: symfony
database_user: root
database_password: root
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: 0408312e2b9861c0c86dbb7488aceec4296054ec
database_path: /Applications/MAMP/tmp/mysql/mysql.sock
The tutorial talks updating the database_* options in the parameters file located at app/config/parameters.ini. However, I don't have a parameters.ini file located in this folder! Only parameters.yml.
Edit: Solution:
I was using the wrong port number for MySql. When I used 3306 it worked.
I was using the wrong port number for MySql. When I used 3306, the standard mysql port, it worked.
(Thank you jperovic)

Resources