SMTP hosts:
smtp.sendgrid.net:465
SMTP security:
TLS
SMTP Auth Type:
LOGIN
SMTP username:
my_sendgrid_api_key_id
SMTP password:
••••••••••••••••••
SMTP session limit:
1
Finally made it:
Hi Adam, What is the Sendgrid configuration you are using?
On the moodle side I put the same as you and still keep getting error 504
This is my Api Key configuration
i've given a full access to my API key, but that is not the best solution honestly. I didn't try if it would work with restricted access (just Mail Send), as it should be set up, and as you have done.
Check if your Moodle server's IP is whitelisted on Sendgrid and also check if your firewall is open on email ports: 25, 465, 587, 993 etc..
If none of those help, try to install this plugin https://moodle.org/plugins/local_mailtest maybe it'll tell you something new..
I was able to figure it out thanks to you pointing me in the right direction!
SMTP hosts: smtp.sendgrid.net:587
SMTP security: TLS
SMTP Auth Type: LOGIN
SMTP username: apikey
SMTP password: provided by SendGrid
SMTP session limit: 1
I left my SendGrid API Key Permissions on the default of Restricted Access and added my server's IP address to the SendGrid whitelist.
Edit: After looking back at the original question, it looks like my settings are the same as the original poster. I did set the No-reply address to something other than the Moodle default, not sure if that made a difference or not.
I got mine working with the following SendGrid config
SMTP hosts: smtp.sendgrid.net:465
SMTP security: SSL
SMTP Auth Type: LOGIN
SMTP username: apikey
SMTP password: provided by SendGrid
SMTP session limit: 1
Here are the steps, for anyone confused about how how to change a Moodle using SendGrid for outgoing email, to one using SendGrid API -- as SendGrid is requiring you to do now (October 2020).
- Sign in to your sendgrid.com account.
- In the left column, click on Email API, then Integration Guide
- In the page labeled "Integrate using our web..." choose SMTP Relay
- Click Create API Key, then SAVE IT! -- it will disappear after you read it.
- Leave this page open, you will return to it in a minute.
- In another browser tab, log in to your Moodle, go to Site Administration/Server/Outgoing mail configuration
- Set it up like this:
SMTP hosts: sendgrid.net:587
SMTP Security: TLS
SMTP Auth Type: LOGIN
SMTP username [yes, enter "apikey" as your username]: apikey
SMTP password: HERE ENTER THE API KEY YOU JUST GENERATED ON SENDGRID AND COPIED
- At the bottom of the page, click Save Changes.
- Return to SendGrid.com, check the box that you have updated your settings, then click "Next Verify Integration."
- Follow the steps for verifying that this email setting works.
- Still on SendGrid.com, open your Account and set up two-factor authentication, which they now require. DO NOT DO THIS UNTIL AFTER YOU HAVE INSTALLED THE API KEY in your Moodle. Then sign out of SendGrid and verify that the two-factor authentication works.
You might want to force Moodle to send another email, to be doubly sure the emails are working.
You can do this by going to the Moodle login and checking "Forgotten your password." That should send you an email from the Moodle you just updated. If you do not see this email, be sure to check your email client's Spam and Trash folders.
I hope this includes everything, for those of us who are easily confused.
I did everything and with several tests, this worked for me:
smtphosts smtp.sendgrid.net:465
seguridad SMPT SSL
SMTP Auth type LOGIN
Nombre de usuario apikey
Contraseña escribir la proveida por el servidor
Límite de sesión 1
This just worked for me. Thanks!
Running 3.9 in UBUNTU 20
Be sure to check the Live Logs for the reason why your message failed!
In my case it was because I was sending from noreply@subdomain.domain.com. Once I changed it to noreply@domain.com (where domain is my actual domain name), everything suddenly started working perfectly.