Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hjortur17's avatar

SendGrid

I'm trying to setup SendGrid to work with Laravel, do you need any magic trick because it wound verify.

This is the config, SendGrid provide:

Server  smtp.sendgrid.net
Ports   
    25, 587 (for unencrypted/TLS connections)
    465 (for SSL connections)
Username    apikey
Password    YOUR_API_KEY

What is suppose to be in apikey? Is it the name I give the api or just apikey?

Here is what I'm doing in Laravel:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=parkandfly
MAIL_PASSWORD=SG.****

parkandfly is the name of the api

0 likes
8 replies
Snapey's avatar

On Sendgrid site, look in Settings->Api keys

hjortur17's avatar

I always get this in my log:

Failed to authenticate on SMTP server with username "parkandfly" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 250 but got an empty response. Authenticator PLAIN returned Expected response code 250 but got an empty response.

Here is how my .env file looks like:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=parkandfly
MAIL_PASSWORD=SG.******
Snapey's avatar
Snapey
Best Answer
Level 122

username needs to be apikey

password needs to be the api key you generated for your application

1 like
briskbase's avatar

After spending 28 hours on this issue the solution is changing the port to 2525 and it's working now. You don't need to change or encode base64.

Using the following settings.

MAIL_MAILER=smtp
MAIL_HOST=smtp[dot]sendgrid[dot]net
MAIL_PORT=2525
MAIL_USERNAME=apikey
MAIL_PASSWORD=sendgrid_apikey
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@example[dot]com
MAIL_FROM_NAME="${APP_NAME}"
1 like
marcellopato's avatar

That worked for me. Changing the port number to 2525 and keep the username as 'apikey'

Please or to participate in this conversation.