ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 3 replies, has 2 voices, and was last updated by  jakabadambalazs 2 years, 2 months ago.

  • Creator
    Topic
  • #10385

    jakabadambalazs
    Participant

    Hi,

    I am trying to implement a functionality with which user can specify his own settings for sending mail(SMTP config).

    What I came up with is to overwrite the oro_email.direct_mailer service defined in EmailBundle in my own bundle (loaded after) with this:

    And in my own class I created the necessary modifications for this to work.

    The thing works.
    My question is: Is this the correct way to do this?

    thanks?
    a\


    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)

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

    Hello, jakabadambalazs!

    Your approach seems fine. There is also another way to achieve your goal described at Symfony documentation:
    Configuring Services with a Service Configurator

    A Service Configurator can be used, for example, when you have a service that requires complex setup based on configuration settings coming from different sources/services

    #10389

    jakabadambalazs
    Participant

    Hi @krlove,

    Thanks, I think I’ll go by the service configurator way – I didn’t know about this!
    Even the example on the symfony documentation is close to what I am trying to do 😉

    a\


    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)

    #10390

    jakabadambalazs
    Participant

    eeehm, maybe I spoke too fast.

    If I wanted to use the “service configurator” method I’d need to:
    1) create a configurator service(@my_configurator) with a ‘configure’ method on it which would configure the DirectMail service.
    2) modify the ‘oro_email.direct_mailer’ service definition and add ‘configurator: [“@my_configurator”, configure]’

    what I don’t understand is:
    1) I’d need to change the $baseMailer protected variable inside DirectMailer which doesn’t expose a setter method for that so my configure method would not have access to that

    2) even if there was a setter method for $baseMailer, the DirectMailer class extends \SwiftMailer class and it gets constructed with the $transport type based on the $baseMailer (findRealTransport()). I guess that the configuration can take place only after the class was constructed. but \SwiftMailer, one constructed does not allow changing transport type.

    am I getting this right?
    a\


    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)

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

You must be logged in to reply to this topic.