CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Proposed hook for modifying outgoing mail settings
Pages: [1]

Author Topic: Proposed hook for modifying outgoing mail settings  (Read 754 times)

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Proposed hook for modifying outgoing mail settings
February 23, 2013, 12:33:32 am
I've just posted a patch to the trunk that implements a hook_civicrm_alterOutgoingMailParams.  I needed it because I needed to make the Mailer object that wraps sending mail to set its parameters dynamically, since some of our installs use Micah Lee's postfix forwarder technique, and some don't.

It needed to be a new hook since it turns out that hook_civicrm_config does not have access to the mailer settings -- you can get 'em, but due to the use of private or protected data, you can't set 'em.  So I added a hook to let you go in and adjust the settings just before the Mailer object is instantiated.

I have the draft implementation up in JIRA, at http://issues.civicrm.org/jira/browse/CRM-11958.  If you need a hook that does something like this, by all means try the patch and kick the tires.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Proposed hook for modifying outgoing mail settings
February 27, 2013, 11:25:24 am
Hi,

Wouldn't it make sense to rather alter the civicrm_config so it can modify the mailer setting instead of creating a new hook?

I didn't check out the public private issue, but wouldn't it solve the problem to either make it public or add a setter method?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: Proposed hook for modifying outgoing mail settings
February 27, 2013, 03:31:34 pm
Quote from: xavier on February 27, 2013, 11:25:24 am
Hi,

Wouldn't it make sense to rather alter the civicrm_config so it can modify the mailer setting instead of creating a new hook?

I didn't check out the public private issue, but wouldn't it solve the problem to either make it public or add a setter method?

X+

I considered that, although it's not a trivial change.

The problem is that, as you know, settings are gradually migrating from the huge lump that lives in civicrm_domain, into the (relatively) new civicrm_setting table.  A lot of settings that come in via the newer code path are effectively read-only right now.  This includes all of the settings that define the "mailing_backend" group used by CRM_Core_Config::getMailer().  Exposing those settings via the $config object is not altogether trivial, and since everything uses that object, side-effects are more likely than usual.

Since I wanted a change I could do quickly and would have a high probability of getting into 4.3, I chose to create a new hook, since I could patch the trunk in a very clean way that was unlikely to break anything else.  But yes, it probably would make sense to make sure that all of the mailing settings got into the main CRM_Core_Config name space, so that hook_civicrm_config could be used for this sort of thing.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Proposed hook for modifying outgoing mail settings

This forum was archived on 2017-11-26.