I want to send a confirmation e-mail using laravel. The laravel Mail::send() function only seems to accept a path to a file on the system. The problem is that my mailtemplates are stored in the database and not in a file on the system.
How can I pass plain content to the email?
Example:
$content = "Hi,welcome user!"; Mail::send($content,$data,function(){});
update: In Laravel 5 you can use raw
instead:
Mail::raw('Hi, welcome user!', function ($message) { $message->to(..) ->subject(..); });
This is how you do it:
Mail::send([], [], function ($message) { $message->to(..) ->subject(..) // here comes what you want ->setBody('Hi, welcome user!'); // assuming text/plain // or: ->setBody('<h1>Hi, welcome user!</h1>', 'text/html'); // for HTML rich messages });
For Html emails
Mail::send(array(), array(), function ($message) use ($html) { $message->to(..) ->subject(..) ->from(..) ->setBody($html, 'text/html'); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With