Try to use Symfony mailer with Gmail on my Symfony 5.1 app.
mailer.yaml:
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
.env:
MAILER_DSN=gmail+smtp://myadresse#gmail.com:mypassword#localhost
But each time I send a mail, I got:
Connection could not be established with host "ssl://smtp.gmail.com:465": stream_socket_client():
SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Don't understand why... According to the https://symfony.com/doc/current/mailer.html it should work.
I activated low security app on my Gmail account.
Thanks for help
To use Gmail, you need the package symfony/google-mailer (composer require symfony/google-mailer)
And this configuration in your .env file:
###> symfony/google-mailer ###
# Gmail SHOULD NOT be used on production, use it in development only.
MAILER_DSN=gmail://YourEmailAddress:YourPassword#default?verify_peer=0
###< symfony/google-mailer ###
An example:
MAILER_DSN=gmail://stackoverflow#gmail.com:admin123#default?verify_peer=0
Warning:
Although it’s not recommended to disable this verification for
security reasons, it can be useful while developing the application or
when using a self-signed certificate
I know you've said you've done it, but I usually get this error because I need to allow "less secure apps" on my Gmail account.
Connect to Gmail
Go to https://www.google.com/settings/security/lesssecureapps and click Authorize
Go to https://accounts.google.com/DisplayUnlockCaptcha and click Continue
Retry sending an email from your website, and if it still doesn't work repeat points 2 & 3. Sometimes I have to try a few times...
That can come from an async property that is defined by config/packages/messenger.yaml
see https://github.com/symfony/symfony/issues/45811
You need to make sure you are using an SSL certificate when sending emails through Gmail.
See:
https://symfony.com/doc/3.0//email/gmail.html
Related
I got some trouble with mails generation on my Symfony app :
I use docker
when I use Gmail to send emails :
MAILER_URL=gmail://MyAddress#gmail.com:MyPw#localhost
everything works fine
but as soon as I try to intercept these mails :
======================
Like this for mailtrap
MAILER_DSN=smtp://b3f077aeceaeb6:8792a1811dd8ef#smtp.mailtrap.io:2525?encryption=tls&auth_mode=login
MAILER_URL=smtp://smtp.mailtrap.io:25&auth_mode=login&username=b3f077aeceaeb6&password=8792a1811dd8ef
or like this for mailHog
MAILER_DSN=smtp://localhost:1025
MAILER_URL="smtp://mailhog:1025?encryption=ssl&auth_mode=login&username=null&password=null"
my docker-compose.yml looks like this :
mailhog:
container_name: mailhog
restart: always
image: mailhog/mailhog:latest
ports:
-'8025:8025'
-'1025:1025'
Does anyone know how to see the mails displayed in mailhog? mailhog page is loaded correctly but nothing shows in it.
The function sending the mail is entered, so this must be a configuration problem in my opinion
Based on your post, I had a similar problem with mailhog and SwiftMailer for Symfony.
I ended up using the smtp for both MAILER_DSN and MAILER_URL as follows
MAILER_DSN=smtp://localhost:1025
MAILER_URL="smtp://localhost:1025?auth_mode=login"
As you can see the trick was to remove encryption=ssl as the mailhog does not supports it and the username=null&password=null as the software sends it as literal string "null".
Besides, in my swiftmailer.yaml and mailer.yaml I have this very simple configuration
# swiftmailer.yaml
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
# mailer.yaml
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
You need to narrow down the issue.
1. Can you send you an email via telnet or openssl (in case of STARTTLS)?
Via telnet: https://mediatemple.net/community/products/dv/204404584/sending-or-viewing-emails-using-telnet
Via OpenSSL: https://www.stevenrombauts.be/2018/12/test-smtp-with-telnet-or-openssl/
Go through the tutorial (or any on this topic) and make sure your MAILER_URL is correct (including credentials, port, etc). The last time I had some issue with email, turned out that the firewall was blocking me.
Don't be quick to rule out networking issues.
2. Once you confirmed that you can send an email via Telnet/OpenSSL:
you need to go level up and try to configure the URL in Symfony and attempt sending via swiftmailer:send command. This may reveal some odd configuration issues in Symfony and you can fix them accordingly
3. Repeat (1) and (2) but from Docker container.
Just exec into Docker and do it all over again. This may reveal some issues in Docker network configuration, which you can fix.
Please update your question with more findings and we could probably help you further...
I am trying to configure alfresco 5.0d community to use kerberos and SSO via active directory.
My setup works fine when I login in the alfresco form login page (without SSO),
However, When enabling SSO, I see this exception in the alfresco logfile:
KrbException: KDC cannot accommodate requested option (13)
at sun.security.krb5.KrbTgsRep.<init>(KrbTgsRep.java:70)
at sun.security.krb5.KrbTgsReq.getReply(KrbTgsReq.java:259)
After looking at it with wireshark, it seems like the difference in the TGS-REQ message is that when using SSO, there is an option flag called request-anonymous that is enabled. This causes the KDC to answer with a KDC_ERR_BADOPTION message.
Is there a way to configure kerberos to not set the request-anonymous flag?
Or alternitavely, is there a way to tell the KDC server to deal with it properly?
I am working on a Symfony2 app. I'm using FOSUserBundle to handle authentication and recently integrated it with FOSUserBundle using this tutorial: https://gist.github.com/danvbe/4476697 .
The problem is:
I can login using the google api on localhost and everything works fine.
However when I try to login on a real server I get:
Error: invalid_request
device_id and device_name are required for private IP: http://<server_ip>/login/check-google
Request details:
response_type=code
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
redirect_uri=http://<server_ip>/login/check-google
client_id=<my_id>
Google documents don't mention these two parameters. I tried to manually send a request with device_id being a UUID and device_name set to "notes". The response I get this time is:
Error: invalid_request
Device info can be set only for native apps.
Request details:
cookie_policy_enforce=false
response_type=code
device_name=notes
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
redirect_uri=http://<server_ip>/login/check-google
device_id=4b3403665fea6
client_id=<my_id>
Now, what am I doing wrong?
Google will not accept a local (private) IP address when doing Oauth or API calls. My workaround was to add an entry in my Windows hosts file for the local IP:
\Windows\System32\drivers\etc
192.168.1.2 fakedomain.com
then register it with Google in their dev console. That appears as a "real" domain to them, but will still resolve in your browser or code to the local IP. I'm sure a similar approach on Mac or Linux would also work.
It really looks like your using the wrong flavor of oauth. device_id is used with Devices. I would really expect you to be using the WebServer flow. You may need one of the other flows as I don't see enough detail here to judge, but they all can be found at the links.
I am trying to run the pushtest sample that ships with the iOS SDK. In the .m file I have replaced the org name, app name and notifier name( which I have named 'apple'). I have the provisioning set up for my iPad. When I run the code, I don't see any window asking me to allow push notifications. On clicking the push to this device, the terminal spits out this error:
2014-01-30 14:04:20.525 Push Test[2970:60b] displaying alert. title: Error, message: {"error":"unauthorized","timestamp":1391119457656,"duration":0,"exception":"org.apache.shiro.authz.UnauthorizedException","error_description":"Subject does not have permission [applications:post:ed031740-7e90-11e3-a906-25e89414fcd7:/notifications]"}
I believe this is because the app has not obtained push permission, however, the alert window asking for this was not presented in the first case. How can I fix this?
"error":"unauthorized"`
This is an indication that your request requires authentication and you're not authorized to access the endpoint.
Push notifications out of the box require authentication - either an access_token (recommended) or client_id/secret. Try including the access_token in your header (instructions here).
If you want to disable authentication, you can add the GUEST role to /notifications (instructions here).
You need to give permissions to your application role:
curl -X POST "https://api.usergrid.com///roles/ -d '{"name":"nameforrole","title":"titleforrole","permission" : "GET,PUT,POST,DELETE:/users/me/**"}'
I'm using
Configure SMTP plugin for wordpress, when I used it in a local server (localhost) it works properly and send me the test email which confirms that it is working. But when I used it in a hosting site (I used Hostgator) it gives me an STMP error.
What is the possible cause of this error? and what is the possible solution?
Thank you.
Based on the second error, and the words "verification failed", and "sender verify" failed, my guess would be that you have not set up SMTP authentication correctly. You are relaying your mail through Hostgator, so they may have specific hostnames / ports that you need to authenticate correctly with to get your mail to flow. I'd suggest syncing with Hostgator on this.