OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions How to send an email which gets logged

This topic contains 3 replies, has 2 voices, and was last updated by  Andrey Mishchenko 8 years, 10 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #35975

    cardiac
    Participant

    Hi all,

    I currently try to send an email through OroPlatform and I want the email to get logged.
    I have a new entity and want to send an email onPersist. But I want the email to get displayed in entity like user emails do.

    Can you give me a hint or an example how to do it the best way?

    First I tried a service with an doctrine listener but I needed config and entity manager and so there was a dependency problem. Now I send the mail with a job which gets trigger by the event listener.

    How do you do it?

    Best regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #35976

    Andrey Mishchenko
    Participant

    Hello, cardiac!

    Take a look at https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/ActivityBundle/README.md. `How to enable activity association using migrations` chapter describes how to add email activity association to an entity. In your case it will be something like

    To assign specific email to specific entity you should use Oro\Bundle\EmailBundle\Entity\Manager\EmailActivityManager::addAssociation() method.

    To automatically render related activities you should extend your entitie’s view template from OroUIBundle:actions:view.html.twig.

    Best regards

    P.S. Could you also provide more information about dependency problem you get while using doctrine listener?

    #35977

    cardiac
    Participant

    First: Thank you for you help! I will try you solution later on.

    P.S. Could you also provide more information about dependency problem you get while using doctrine listener?

    Sure.

    I created a LeadMailProcessor which depends on:
    – @doctrine.orm.entity_manager
    – @oro_config.global
    – @oro_email.email_renderer
    – @oro_email.direct_mailer

    If you try to inject this service to the event listener, you will get an error with the injected services entity manager and config manager. (Something like dependency loop – do not know the exact error message).

    I’m currently using a job to avoid this problem.

    #35978

    Andrey Mishchenko
    Participant

    Thank you for providing additional information.

    Try to inject @doctrine instead of @doctrine.orm.entity_manager into your service and use getManager method to retrieve an instance of EntityManager inside the service.

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

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

Back to top