sabeena's avatar

Sending Email in Laravel

Hi all, i am newbie to laravel, i want to develop email module in laravel it can be used thoughout the application.

say, ecommerce website it will send mail while registration. while order the goods, etc,

i need an advice regarding

  1. is saving html mail body in DB is good over creating mail body as view?
  2. which laravel functionality is good to implement sending mail module thoughout the app?
0 likes
6 replies
sabeena's avatar

sure it is, but i want know which way is good to proceed. 1.is saving html mail body in DB is good over creating mail body as view?

nikocraft's avatar

I would create mail body as view unless you are going to be making a solution where your customers want to customize the mail template. in that case you would want perhaps to save it to database.

1 like
ejdelmonico's avatar

Just make a mailer.php helper class file with the necessary code from the docs. Make a view for your mail and off you go.

jekinney's avatar
jekinney
Best Answer
Level 47

What I do for dynamicly creating templates is save the form input as a file. To keep with view process provided by defaults I save them in views/email. Though technically you can save where ever. With blade.php at the end of the file name.

Save the file location, file name and meta data (name, use etc..) in a db table. When you fire off an email use the file name variable as the view and use any dynamic data as per the docs.

When a user updates, I find it easier to replace the file (delete current and save new).

sabeena's avatar

Thanks everyone for the valuable suggestions...

Please or to participate in this conversation.