Forums › Forums › OroCRM › OroCRM – How do I? Questions › Use Email template as services
This topic contains 11 replies, has 5 voices, and was last updated by soloulearn 4 years ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- December 19, 2015 at 8:02 am #28698
Hi,
Is it possible to use email template as services for example in my own controller ?
I have a Job which have to send mails based on template with contact entity, there’s a way to do it as simple as possible?Thanks,
KnutFr - CreatorTopic
- AuthorReplies
- December 22, 2015 at 11:29 am #28699
Hi there,
Maybe calling the EmailTemplate entity? Something like:
PHP1234$this->getDoctrine()->getRepository('OroEmailBundle:EmailTemplate')->findAll();There is other option here: https://github.com/orocrm/platform/blob/ae09ef7175a0febc079b33d7a0b4d2ceab7cbc91/src/Oro/Bundle/UserBundle/Mailer/BaseProcessor.php#L81
January 7, 2016 at 7:47 am #28700Hi,
I have another problem, I have a job which have to send mail to contact when his seniority is updated (every year) but nothing is sended (process execution is successful anyway).
My process.yml:
YAML123456789101112131415161718192021definitions:send_mail_wedding: # name of process definitionlabel: 'Anniversary Wedding Process' # label of the process definitionenabled: true # this definition is enabled (activated)entity: Oro\Bundle\ContactBundle\Entity\Contact # related entityorder: 20 # processing orderactions_configuration:- @send_email_template:from: 'contac@egsrcn.com'to: $emailtemplate: 'wedding_anniversary'entity: $contacttriggers: # list of triggerssend_mail_wedding: # Trigger on start_process field change-event: update # event on which the trigger performedfield: seniority # field name to listenpriority: 0 # priority of the job queuequeued: true # this process must be executed in queuetime_shift: 0 # this process must be executed with 60 seconds delayEverything is set, my mail template, my contact entity.
Am I doing something wrong ?KnutFr
January 7, 2016 at 7:51 am #28701I can see that it’s being queued. Is your Job-Daemon running? Any logs to help us?
January 7, 2016 at 10:04 am #28702Hi,
Yes it’s always running but my job is a process and doesn’t appear in job queue.
Is there any logs for process ?January 7, 2016 at 11:11 am #28703Did you run this command after you changed the process yml file?
PowerShell1php app/console oro:process:configuration:loadIf you run your application with debug mode /app_dev.php you’ll get a more verbose log on app/logs/dev.log. Otherwise, you can try app/log/prod.log.
I would like to have more experience with Email Process Triggers to help, so good luck!
January 7, 2016 at 3:49 pm #28704There’s nothing on my log and also nothing in my system mail log …
Maybe a mistake in my “actions_configuration” syntax ?
January 19, 2016 at 4:07 am #28705Hello.
Look’s like process configuration is fine (you can omit “time_shift: 0” because it doesn’t do anything in this case). Now the possible reasons why process not executed:
1) process is not uploaded to DB (as @Rodolfo said) or disabled – it can be checked via UI at System > Processes
2) process not triggered because “seniority” field is not changed or entity has no such field (look’s like the most probable reason for me)
Couple of recommendations about process debugging:
– you can make this process not queued, check that it works without queue and only then make it queued again
– when you are testing queued process you can temporary stop job queue daemon, do required action, make sure that job appeared in queue and then start daemon again
– also when daemon is stopped you can manually run command to execute process job and check that it works as expectedAlso, please, remember that job queue automatically cleared every day from successful jobs.
Feel free to post here results of your investigation – I’ll try to help.
January 23, 2016 at 8:31 pm #28706Something similar I have been looking for. Kindly share if you managed to achieve this.
February 6, 2016 at 1:47 pm #28707I haven’t found a solution yet, but how can I send a template mail to a Contact entity in a controler ? (email template is based on Oro Contact Entity).
For example, I have my $contact and my $template returned by Doctrine Entity Manager, there is a way to send it?
Thanks a lot,
KnutFrFebruary 8, 2016 at 3:24 am #28708Sure, you can use SendEmailTemplate::executeAction as an example.
So, you need to create Email object, fill it with data (from, to, subject, type), then render email body based on your template via EmailRenderer::compileMessage method, set this body to email model, and execute email sending via Processor::process.
February 29, 2020 at 7:14 am #41417I even have another hassle, I even have a activity which need to ship mail to contact whilst his seniority is updated (each year) but nothing is sended (procedure execution is successful besides). I’m using temp mail of https://owlymail.com/ for temporary registration.
- AuthorReplies
The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.