I'm trying to send emails via gmail in a Symfony 5 online application.
Here is my configuration (swiftmailer.yaml) :
swiftmailer:
transport: gmail
auth_mode: login
port: 465
host: smtp.gmail.com
username: my_username
password: '%env(MAILER_GMAIL_PASSWORD)%'
spool: { type: 'memory' }
And here is the error that I've got :
app.ERROR: Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "my_username" using 1 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "534", with message "534-5.7.14 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 a10sm1287053wrm.87 - gsmtp ". [] []
I followed the steps on the link in the error (https://support.google.com/mail/answer/78754), and nothing has changed.
Any suggestion?
I fixed my issue deleting this line in configuration of swiftmailer:
auth_mode: login
Related
Symfony version(s) affected: 4.4.3
Mailer component (not swiftmailer)
Description
i try to send a mail on the SMTP server but this one don't have a certicate valid.
So How to disable the ssl ?
How to reproduce
the 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
You can disable it if you'r using swiftmailer
swiftmailer:
stream_options:
ssl:
verify_peer: false
verify_peer_name: false```
I´m working in a localhost server with Symfony 4 and FOSUserBundle. I can't manage to receive the email confirmation when a new user is registered.
I have tried the following post but it´s not working in my case:
Symfony 4 SwiftMailer Gmail : Email not sent
I have tried to configure SwiftMailer to send using gmail smtp server and mailtrap smtp server without success. Also I have checked dev.log and no errors are found.
I´m not sure which is the right file to configure Swift Mailer (.env or packages/dev/swiftmailer.yaml). Right now the configuration is the following:
.env file:
MAILER_URL=gmail://***#gmail.com:***#localhost
swiftmailer.yaml:
swiftmailer:
transport: gmail
username: ***#gmail.com
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
Any ideas? It´s not mandatory to use gmail as the smtp server.
Thanks beforehand.
SOLUTION:
The problem was in the /config/test/fos_user.yaml file:
I changed:
service:
mailer: 'fos_user.mailer.noop'
To:
service:
mailer: 'fos_user.mailer.default'
Documentation: http://symfony.com/doc/master/bundles/FOSUserBundle/emails.html
Also I have accepted less secure connections from the gmail account setting in order to work.
I had the same problem with Symfony 4. My packages version
swiftmailer/swiftmailer v6.1.0
symfony/swiftmailer-bundle v3.2.2
When I used configuration:
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
The emails were not send and no exception occurred.
Then I change the settings into:
swiftmailer:
url: '%env(MAILER_URL)%'
spool:
type: 'file'
path: '%kernel.cache_dir%/swiftmailer/spool'
And tried command:
php bin/console swiftmailer:spool:send --env=dev -vvv
And I saw the error:
[Swift_SwiftException]
No IDN encoder found (install the intl extension or the true/punycode package
So I installed true/punycode package via:
composer req true/punycode
and now emails are sending fine also with spool memory.
Default behaviour of Symfony mailer is to send the email messages immediately, but as you configured, it will "spool" the emails instead of sending them directly.
spool: { type: 'memory' }
Sending the messages from the spool is done separately, with a console command:
php bin/console swiftmailer:spool:send --env=dev
#see more docs here
UPDATE:
As #nek said on the first comment, the the memory spool send the mail immediately (if none exception occured). The spool:send command is only required when using the file spool.
I am getting the following error (using the WP Mail SMTP Plugin).
Any idea how to resolve this?
(All ports, passwords, etc are correct)
Thanks
Versions:
WordPress: 4.9.1
WordPress MS: No
PHP: 5.6.31-4+wpengine10
WP Mail SMTP: 1.2.2
Params:
Mailer: smtp
Constants: No
ErrorInfo: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Host: smtp.hosts.co.uk
Port: 465
SMTPSecure: ssl
SMTPAutoTLS: bool(false)
SMTPAuth: bool(true)
Server:
OpenSSL: Yes
SMTP Debug:
2018-01-15 15:54:32 Connection: opening to ssl://smtp.hosts.co.uk:465, timeout=300, options=array ()
2018-01-15 15:54:39 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to ssl://smtp.hosts.co.uk:465 (Connection timed out)
2018-01-15 15:54:39 SMTP ERROR: Failed to connect to server: Connection timed out (110)
2018-01-15 15:54:39 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
It looks like your ISP is blocking outbound SMTP. How to diagnose this is covered in the troubleshooting guide linked from the error message.
I can get to your host on that port, so it's definitely an issue with your network, not your code. You should ask your ISP or read their support docs about how they want you to send email.
I developed my site with WordPress 4.5.3.I installed plugin WP-Mail-SMTP.I create mail account with my host tigrimigri.com.
with this setting
Secure SSL/TLS Settings
Username: Your Email Address
Incoming Server: freehost.tigrimigri.com
IMAP Port: 993
POP3 Port: 995
Outgoing Server: freehost.tigrimigri.com
SMTP Port: 25
Then I write this info at plugin WP-Mail-SMTP setting
But when I test email I get this error
The SMTP debugging output is shown below:
2016-07-02 12:21:04 Connection: opening to ssl://freehost.tigrimigri.com:25, timeout=300, options=array (
)
2016-07-02 12:21:04 SMTP ERROR: Failed to connect to server: Connection refused (111)
2016-07-02 12:21:04 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Please anyone help me.
I think you can not sent mail through freehost.tigrimigri.com
Check the faq section on the site:
http://tigrimigri.com/faq.html
Can I use e-mail?
Sorry it is not possible yet to sent / receive e-mail through our server.
I'm trying to send emails using gmail configuration but I can't.
I'm not having any errors; I also checked the symfony log files.
Nothing crashed, but no emails are sent :(
I also ran the swiftmailer:spool:send command (maybe the emails were in the spool) and as a result I received: sent 0 emails.
I'm using the dev environment, in my config_dev.yml:
swiftmailer:
transport: gmail
username: myuser#gmail.com
password: mypass
In the controller(just for test):
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send#example.com')
->setTo('myemail#mydomain.com')
->setBody(
"some test body"
)
;
$this->get('mailer')->send($message);
Thanks in advance
UPDATE:
I switch to prod environment, same results: no errors... until i ran the command and I got this error:
[Swift_TransportException]
Connection could not be established with host smtp.gmail.com [Unable to fin
d the socket transport "ssl" - did you forget to enable it when you configu
red PHP? #50346848]
Then, I uncomment this line in the php.ini
extension=php_openssl.dll
but nothing, the same result :(
I also modified the memory to file in swiftmailer config and the email is there, in cache:
app\cache\prod\swiftmailer\spool
PS: I'm not behind any proxy
Did you check the profiler (you can know if some emails were sent, or at least spooled)? Did you try in the prod environment ?
I remember a similar issue with Swiftmailer on a dev env in a project I did. To test it, I changed spool: { type: memory } to spool: { type: file } and I checked the mails in the dev cache directory.