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.
Related
Older Versions of Contao (till 4.3) working like expected with sending emails via sendmail.
After upgrade to Contao 4.9 I got some errors at Providers like 1u1 / ionos or mittwald.
The error in the logs sound like:
"Expected response code 220 but got an empty response"
Sending Mails from CLI of the Server (means if logged in via SSH) working like expected:sendmail test" |
/usr/sbin/sendmail -t -v -f sender#domain.com reciepient#otherOne.com
The solution is to add this to config/config.yml
swiftmailer:
default_mailer: default
mailers:
default:
url: '%env(MAILER_URL)%'
transport: sendmail
command: '/usr/sbin/sendmail -t -i'
After that, clear the Contao-Cache (e.g. via contao-manager.phar) and give it a try.
The reason for that issue is, that by default the swiftMailer use sendmail -bs as command, which means that sendmail run as standalone Service.
Depending at the way your provider configure it's sendmail, this will be the cause of the error.
If you update symfony/swiftmailer-bundle to version 3.5.0, then the default value used for the sendmail command will be read from the PHP configuration. See https://github.com/symfony/swiftmailer-bundle/pull/302
So provided the PHP configuration of your hosting environment contains the correct command in sendmail_path, sending emails should work without any changes.
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
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 experiencing some issues with Ionos smtp configuration.
I use Swiftmailer with Symfony 4.
On local i receive my email using mailtrap or gmail, but on ionos's server it doesn't work with gmail or the SMTP configuration.
Here is my .env with different configs :
###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://email#gmail.com:PSW#localhost" <-- Work in local but not on Ionos
# MAILER_URL=smtp://smtp.mailtrap.io:2525?encryption=tls&auth_mode=login&username=LOGINMAILTRAP&password=PASSWORDMAILTRAP <-- Work in local and Ionos
MAILER_URL=smtp://smtp.ionos.fr:587?encryption=ssl&auth_mode=login&username=contact#mydomain.com&password=PWD <-- Doesn't work using Ionos SMTP config
###< symfony/swiftmailer-bundle ###
Here is my swiftmailer.yaml :
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
https://symfony.com/doc/current/email.html#configuration
If the username, password or host contain any character considered special in a URI (such as +, #, $, #, /, :, *, !), you must encode them. See RFC 3986 for the full list of reserved characters or use the urlencode function to encode them.
Try changing the encryption, from ssl to tls.
Here is an example:
MAILER_URL=smtp://smtp.ionos.fr:587?encryption=tls&auth_mode=login&username=contact#mydomain.com&password=PWD
And make sure to urlencode the password if it contains any special charater, as mentioned by #Fisher
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.