cancel
Showing results for 
Search instead for 
Did you mean: 

How to send email in cron using admin created template

How to send email in cron using admin created template

Hey,

 

I have a cron module and the ideia is that he sends an email, but I need that the email template comes from the admin area and can be edited there, I saw some way to do that in Magento 1 but can't find how to do that in Magento 2, how can I do this?

 

And then, what's the best way to send an email in a cron? I saw a lot of examples but all different.

 

Thanks Smiley Very Happy

2 REPLIES 2

Re: How to send email in cron using admin created template

Hi @rui_silva1 

You need to create separate command for send email functionality and set with cron tab as well.

kindly refer below link for set cron tab :
https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-cron.html

Kindly refer below link for create custom command where you can add your functionality for send emails:
https://www.mageplaza.com/magento-2-module-development/magento-2-how-to-add-command-line-console-cli...


If issue resolve, please click on 'Kudos' & Accept as Solution!


Problem solved? Click Accept as Solution!

Re: How to send email in cron using admin created template

Hey thanks,

 

I already have a cron, in this case just writing in a log so I can see it is working.

My problem resides in what to do in the cron so I can get the template from the admin area and send it.

Sorry if I misunderstood something

 

https://www.rakeshjesadiya.com/send-mail-from-custom-module-magento-2/

I want something like this I think, but sending a template that can be edited in the admin area.

 

I can go directly to database email_template table and get the info from there, but I bet there is a better way than just rip that out of the database directly and use it

 

Thanks Smiley Very Happy