I was coding a web APP using the lumen framework on windows with xampp, but after a few issues with routing and so own, I decided to give homestead and vagrant a try.
I managed to get homestead installed and the routing is working better than xampp, but when I tried to use the mail function from php I found that command sendmail wasn't installed on the homestead virtual machine cause i was getting a 500 internal server error, and with xampp email sending was working just fine. So with shh I did a simple sudo apt-get install sendmail to install it. But when now whenever I try to use the mail function from php it just waits and waits and eventually I get a 504 Gateway Time-out.
What might be happening and what can I do to solve it?
BTW: If you have any suggestions to replace the simple mail function for something else that works I'm willing to try it!
Thank you guys for your time.
This is my .env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomKey!!!
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
DB_CONNECTION=sqlite
DB_FILE=database.sqlite
DB_DATABASE='storage/database.sqlite'
DB_DRIVER=sqlite
CACHE_DRIVER=memcached
SESSION_DRIVER=memcached
QUEUE_DRIVER=database
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=[mailtrap_username]
MAIL_PASSWORD=[mailtrap_password]
MAIL_FROM_ADDRESS=example@example.com
MAIL_FROM_NAME=Example
Personally when in development I like to use the log
driver. This writes any emails sent into the storage/logs/
log file. I find this more convenient as it totally ensures no mail is accidentally sent when testing.
If you did want to actually send mail then I'd suggest mailgun, its free for 10,000 emails every month and I use this for every app I've built at work. Super quick and convenient, also includes tracking, delivery confirmation, etc.
After you've signed up you'll want to setup a new domain which will give you several credentials you'll need to add to your config/services.php
, those being your domain and API key.
You'll then need to install guzzle for your application (this is need as mailgun uses a HTTP API to send email, which is much quicker than SMTP and traditional mail transport options).
composer require "guzzlehttp/guzzle": "~5.3|~6.0"
The final thing would to then be set your mail driver to mailgun
and you should be well on your way.
Edit: Looking through the config files of laravel/lumen-framework
doesn't look like its possible to be able to supply the relevant information to be able to use mailgun, or any service that requires information from the services.php
config file as this isn't included in lumen for some reason.