Do you mean sendmail integrated with laravel ? . Present your .env file
Sendgrid config
Hi,
Is anyone using sendgrid to send e-mails?
Are you using username/password or an API key?
I'm not getting e-mails and I can't see any errors.
Cheers,
Mick
Doh, I mean sendgrid. (Edited OP).
Did you follow their guide?
https://sendgrid.com/docs/for-developers/sending-email/laravel/
MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=blahblahblah
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="Me"
MAIL_FROM_ADDRESS="[email protected]"
Mail::to('[email protected]')->send(new TestEmail());
Are you sure that you are allowed to send mails from that yahoo account? There is a good chance that they will not let you send from an external mail server (counts as spam/abuse)
Dont you own your own domain? Set up a proper spf record for that :) https://sendgrid.com/docs/ui/account-and-settings/spf-records/
That isn't the address I am using, I am using the e-mail address that I used to create the sendgrid account.
I am just following the guide. No, I don't currently have a domain.
Ok, are you sure that the email account allows sending from sendgrid? If It doesn't' the email will either bounce, or end up in the spam folder :)
Also tried a gmail one.
Same issue. :) To send from a gmail account you need to allow it in the gmail settings, and use their servers (not sendgrid). You sadly need to use a domain that you control
Yes, send from a domain that you own, otherwise your email will be treated as spoofed.
You may also be able to look in your sendgrid account to see if the number of messages you sent is increasing, and if they are seeing any bouncebacks.
There is also a chance that you can find a test email account inside the sendgrid dashboard :) perhaps something like [email protected]
I don't need a domain, I did this:
https://sendgrid.com/docs/ui/sending-email/sender-verification/
I dont see how that would work.. But do as @snapey said and check the dashboard logs if mails have been sent
Activity feed is empty.
Try checking storage/laravel.log to see if there are any errors
Nope.
OK, change of plan. Forget Sendgrid for now.
What is the simplest way to send mails from Laravel?
If you own a gmail you can use their smtp server :)
https://medium.com/@agavitalis/how-to-send-an-email-in-laravel-using-gmail-smtp-server-53d962f01a0c
What is the simplest way to send mails from Laravel?
Mailtrap.io
Make sure your application is actually generating emails.
OK, I'm trying mailtrap:
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=zzzzz
MAIL_PASSWORD=zzzzz
MAIL_ENCRYPTION=tls
$data = ['message' => 'This is a test'];
Mail::to('[email protected]')->send(new TestEmail($data));
mail.php
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
Still nothing.......
Any chance your config is cached?
php artisan config:clear
Nope but cleared anyway.
Sheesh, I was doing this in a test, I tried in web.php and it worked.
Take a look at what was lurking in phpunit.xml:
<server name="MAIL_MAILER" value="array"/>
Thanks for your help and patience!
Mick
Oh. Yes real mails should not be sent from tests.. That is by design. Remember to tell us stuff like that ;)
I know, I wasn't even really writing a test, just tinkering.
And when I go back to Sendgrid I get:
Blocked
Unauthenticated email from whereIwork.com is not accepted due to domain's DMARC policy
I guess, this is as good as working.
Yeah that sounds about right :) You need to validate the domain (spf and such) to send with it properly :)
Please or to participate in this conversation.