Category: Laravel

Passionate full-stack developer with an eye for usability and carefully crafted interfaces. I keep forgetting how to send an email in Laravel without using Mailables. The the documentation does not help so I’m writing this down here for future reference.

In order to send a raw message (in plain text) you can use the raw method of the Mail facade: On the other hand, an html message can be sent with the html method: There’s also another method, called plain, which sends plain text emails with variable substitution: All these 3 methods use send under the hood, so you can actually provide any combination of html, text and raw content: The priority is always sequential, therefore if the html content is provided then it will be set as body on the Symfony SwiftMailer, otherwise Laravel will try to set either the plain text or the raw part. As a rule of thumb, if you’re going to send a HTML email, always include a plain-text equivalent of the same content so that users who prefer to read plain text can do so.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners