OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

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.

  • Creator
    Topic
  • #28698

    KnutFr
    Participant

    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

Viewing 11 replies - 1 through 11 (of 11 total)
  • Author
    Replies
  • #28699

    Rodolfo
    Participant

    Hi there,

    Maybe calling the EmailTemplate entity? Something like:

    There is other option here: https://github.com/orocrm/platform/blob/ae09ef7175a0febc079b33d7a0b4d2ceab7cbc91/src/Oro/Bundle/UserBundle/Mailer/BaseProcessor.php#L81

    #28700

    KnutFr
    Participant

    Hi,

    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:

    Everything is set, my mail template, my contact entity.
    Am I doing something wrong ?

    KnutFr

    #28701

    Rodolfo
    Participant

    I can see that it’s being queued. Is your Job-Daemon running? Any logs to help us?

    #28702

    KnutFr
    Participant

    Hi,

    Yes it’s always running but my job is a process and doesn’t appear in job queue.
    Is there any logs for process ?

    #28703

    Rodolfo
    Participant

    Did you run this command after you changed the process yml file?

    If 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!

    #28704

    KnutFr
    Participant

    There’s nothing on my log and also nothing in my system mail log …

    Maybe a mistake in my “actions_configuration” syntax ?

    #28705

    Yevhen Shyshkin
    Participant

    Hello.

    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 expected

    Also, 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.

    #28706

    dwijadas
    Participant

    Something similar I have been looking for. Kindly share if you managed to achieve this.

    #28707

    KnutFr
    Participant

    I 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,
    KnutFr

    #28708

    Yevhen Shyshkin
    Participant

    Sure, 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.

    #41417

    soloulearn
    Participant

    I 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.

Viewing 11 replies - 1 through 11 (of 11 total)

The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.

Back to top