Sending emails with mailgun and Laravel


I am trying to learn how to send emails using Mailgun in Laravel. When I try to send the email I get a timeout that says: Maximum execution time of 60 seconds exceeded The application times out here:

$line = fgets($this->_out);

I have a route that activates when I click a button on my email page:

Route::post('/email', '[email protected]');

Here is my controller function (replaced my email for privacy reasons):

    public function sendEmail() {
        $data = [
        Mail::send('emails.hello', $data, function($message) {
            $message->from('[email protected]', 'Example Person');
            $message->to('[email protected]')->subject('we made it');
        return Redirect::to('/');

Any ideas on what I may do be doing wrong?


Sending emails through mailgun could not be simpler, just add the API package, publish and update the config and use the custom facade to send them (changing Mail::send() to Mailgun::send())

You can find the package here:

I know this doesn't really address the error your getting (would need more information to help with that), but using the package does simplify the whole thing!

This generally happens if the SMTP port used in the app/config/mail.php config file is not opened by your hosting provider. Please check and ask them to open the port. This should resolve the issue.

This video can help you solving your question :)
By: admin