Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test php mail() function locally on Homestead

I'm very new to php and am trying to test the mail() function locally. I'm using Homestead/Laravel as a local server. My php.ini file only has one line, where I turn debugging on. Any Homestead/Laravel people out there know how to edit my files so that I can test email locally? Note: I added echo in front of the mail funciton to see if it was working at all.

<?php
$emailTo = "[email protected]";
$subject = "Testing out PHP";
$body = "Huzzah";
$headers = "From: [email protected]";

echo mail($emailTo, $subject, $body, $headers);    
?>
like image 935
Margaret Avatar asked Dec 18 '25 20:12

Margaret


1 Answers

Use:

  • the log driver

    In project/config/mail.php, set the mail driver to log:

    'driver' => env('MAIL_DRIVER', 'log'),
    

    then check your log files for the emails: project/storage/logs/*.log

  • a universal to-address (and send everything to yourself)

  • a dummy mailbox

Check this link for more information: http://laravel.com/docs/5.1/mail#mail-and-local-development

like image 111
Streetlamp Avatar answered Dec 20 '25 11:12

Streetlamp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!