Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nikocraft's avatar

send mail using php mail function with laravel

For example WordPress uses the PHP Mail function to send its emails, how can I do this with Laravel using php built in function to send email so that I don't need to use SMTP etc

0 likes
4 replies
shez1983's avatar

similar way.. just use mail() function..

nikocraft's avatar

is mail() laravel function or are you reffering to php function?

Documentation has this: If you wish to use the PHP mail function to send mail, you may change the driver to mail in the configuration file.

if I change driver to mail can I then do this using Laravel's function: Mail::to($request->user())->send(new OrderShipped($order));

riyas123's avatar

$to = '[email protected]'; $headers = "From: ".$to."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$subject ="Request"; $message = "demo";

mail($to, $subject, $message, $headers)

this is mycode.

can't send mail laravel Please help me

deromanenko's avatar

@riyas123, DO NOT USE PHP 'mail' FUNCTION. Your messages simply wouldn't delivered, cause many Mail providers (Gmail, Outlook, anyone) sending it right to "Spam" folder.

Instead, try to use sending from your mailbox, using smtp connection. Just dive into Laravel Mail or SwiftMailer configuration, it's very easy (swiftmailer easier to understand).

Please or to participate in this conversation.