Demers94's avatar

How to send emails without any services

Hi everyone,

I'm trying to send out a simple email without using any service (mailgun, mandrill, etc).

Here's my .env file :

MAIL_DRIVER=mail
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

It's the default mailtrap stuff, but I changed the MAIL_DRIVER to mail instead of the default smtp.

Whenever I try to send an email, the page just keeps loading until it times out.

What am I doing wrong? Do I need to use the PHP built-in mail() function instead of Laravel's Mail facade? Do I need to fill out some credentials for the username/password when using the default mail driver?

I read in the docs that Laravel is using SwiftMailer, but I can't find any information on how to actually use it.

Thanks for the help!

0 likes
5 replies
Snapey's avatar

You still need to use the services of an SMTP server. This could be your hosting company's, your domain name provider's, your own VPS or your ISP (if local). In most cases you need the IP of the SMTP server and details of the authentication method plus credentials.

Demers94's avatar

Hi @Snapey , thanks for the fast reply!

I'm using Laravel Forge right now with Digital Ocean, do you know where I can find the crendentials and SMTP host to use?

I guess I could also use sendgrid or mailchimp, but it seems overkill to pay for a service like that only to send maybe a dozen emails per day

Snapey's avatar

I would check your domain provider to see if they offer mail services as that is probably the best way to tie it in with return path, DKIM etc.

mikefolsom's avatar

Check out Mailgun or SparkPost. Both have free tiers for low volume and are supported by Laravel's mail services out of the box.

I have also used the built-in mail driver successfully without any other configuration, but PHP has to have access to sendmail: http://php.net/manual/en/mail.requirements.php

I don't believe a Forge-provisioned DO server meets that requirement out of the box...

1 like
abdes's avatar

Update

MAIL_DRIVER=SMTP to MAIL_DRIVER=sendmail

1 like

Please or to participate in this conversation.