I wrote an application in symfony 4.
I deployed it on the heroku.
Everything works as it should with the exception of sending emails.
When I trying to send an e-mail from the console like this:
heroku run php bin/console swiftmailer:email:Send
Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "healthcard95#gmail.com" using 1 possible authenticat
ors. Authenticator LOGIN returned Swift_TransportException: Expected response code 235
Please log in via your web browser and then try again.
Learn more at https://support.google.com/mail/answer/78754 i65sm11848023qkh.49 - gsmtp
" in /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457
This is my swiftmailer.yaml file:
swiftmailer:
transport: gmail
username: username
password: ********
host: localhost
port: 465
encryption: ssl
auth-mode: login
spool: { type: 'memory' }
stream_options:
ssl:
allow_self_signed: true
verify_peer: false
verify_peer_name: false
How to fix this error?
The problem is in Gmail.
Although I have set up security to allow less secure applications and e-mails from local hosts are sent correctly when I perform the same operation in gmail heroku, I see a new device - unfortunately I can't add it to trusted devices, therefore it's blocked.
The solution was to change mail, e.g. on yandex.com.
Here is an example file swiftmailer.yaml correctly configured for heroku:
swiftmailer:
transport: smtp
username: username
password: ********
host: smtp.yandex.com
port: 465
encryption: ssl
auth-mode: login
spool: { type: 'memory' }
stream_options:
ssl:
allow_self_signed: true
verify_peer: false
verify_peer_name: false
Related
I have installed sendmail and it's work's with gmail so it's not a problem.
In swift mailer config yaml it's looks like:
swiftmailer:
transport: smtp
encryption: tls
auth_mode: login
host: smtp.gmail.com
username: (this is my email)
password: (this is my pass)
port: 587
in .env:
MAILER_URL=gmail://username:password#localhost
I get this error:
Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.
OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
I don't know because if i use mail function it's work's fine.
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 }
I am facing issue in Symfony Swiftmailer to send mail.
By Using command:
php app/console swiftmailer:email:send
and this is my swiftMailer.yaml
swiftmailer:
transport: gmail
username: "**************#*******"
password: "****************"
host: smtp.gmail.com
port: 465
encryption: ~
auth_mode: ~
sender_address: ~
antiflood:
threshold: 99
sleep: 0
delivery_addresses: ~
disable_delivery: ~
logging: true
is there anyone know what is the problem ?
If your Gmail account uses 2-Step-Verification, you must generate an App password and use it as the value of the mailer password. You must also ensure that you allow less secure apps to access your Gmail account.
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.
I can't get the file spooling to work properly with Symfony 2 and Swiftmailer.
This is my config
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool:
type: file
path: '%kernel.root_dir%/spool'
port: %mailer_port%
encryption: %mailer_encryption%
sender_address: %mailer_sender_address%
When I send an email, a file is created in app/spool/default/
I then run
php app/console swiftmailer:spool:send
and get this response
[2015-12-29 18:54:40] Processing default mailer... 1 emails sent
So it looks like it has worked, but nothing is sent and /var/log/mail.log does not show any new emails.
When I had the config set to memory spooling, the emails were working without any issue, all I changed was config.yml
swiftmailer:
spool: { type: memory }
changed to
swiftmailer:
spool:
type: file
path: '%kernel.root_dir%/spool'
I'm using sendgrid and postfix to actually send out the emails, but I'm not sure that the emails are even getting to postfix, so that probably doesn't make any difference.
The problem ended up being the default environment. All I needed to do was specify an environment other than dev
php app/console swiftmailer:spool:send --env=prod