I'm looking to rebuild one of my exisiting application using Laravel, basically it allows user to send templated emails to their clients such as 'Your booking has been confirmed' or 'Thank you for using us' etc...
I currently us php's mail() function but I can't seem to find the alternative within Laravel. I want to use the Mail Facade so I can easily access templates as views. I've tried using gmail to send them but the messages end up in my junk.
Mail::send() supports templates and everything you would need from the native PHP mail() function.
I'm not sure if I'm understanding your question entirely. You said you were looking for the alternative to mail() and then said you want to use Laravel's facade which implies that you are aware of the Laravel alternative -- the Mail facade.
Messages that end up in your junk mail may be for a whole host of reasons. Perhaps your junk filters are overly strong, perhaps Gmail thinks that the host you are sending from isn't reliable source, etc.
Thanks for your reply.
What I want to do is use Mail::send() but not have it linked to any email account like how the php mail function doesn't need any authorisation, it just sends....
Hope this makes more sense
In config/mail.php you probably need to change the driver to either "mail" or "sendmail"
I would argue that it's probably better to send out through a gmail account though because the message will appear to be coming from a more reliable source -- meaning your message is less likely to end up in the recipient's junkmail box. Plus you can log into the Gmail account to see bouncebacks and such.
Thanks, I've changed the driver to 'mail' now and it works.
The problem I had with gmail was that the 'from' email address would be my actual gmail address and not the one that I defined when sending the message.
I see. Then gmail probably isn't the right answer. However if you are finding that a lot of the email is ending up in the junk box, you might want to consider some other mail delivery service.
There are plenty of SMTP services out there. The mail.php config file points to mailgun as an example. You'd need to create an account with the service provider you choose and then set your credentials (just like you did for Gmail). You'd also need to return the driver to SMTP.