Customising the Mail Functions

  • CharlieM

    CharlieM - 2011-02-17

    Our server team have control over how PHP is configured on our servers and I need to add a 5th option to the mail command:


    mail($recipient, $subject, $message, $headers, '')

    I'm having difficulty in identifying where I need to make these changes, can you help?

  • - 2011-02-17

    Hi, Charlie!

    Sorry, I cannot quite figure out what you are you trying to accomplish.  Are you asking how to configure your MTA or where is the mail function call you need to modify?

    In the first case it would depend on which MTA you are using (sendmail is just one of many and I don't actually use it at all so I doubt if I can be of much help there).  In the latter case it depends on which email sending function of XRMS you are using (eMailMerge or sending activities).

    Can you be a bit more specific?


  • CharlieM

    CharlieM - 2011-02-17


    Thanks for getting back to me so quickly. I need to identify which files the mail function is called and add the extra parameter. I need to do them all to ensure full functionality.


  • CharlieM

    CharlieM - 2011-02-22

    Can you help with this, I'm eager to get it moving.

  • - 2011-02-22

    Hi, Charlie!

    Sorry for the delay - my Inbox has exploded over the last few days.  I did a quick search through the codebase with the regex


    and, if you are trying to transform all the mail() calls, you will have to look at the following:

      completed-items.php, line 376
      open-items.php, line 366
      overdue-email.php, line 83
      overdue-items.php, line 383
      stale-opportunities.php, line 220
      new-form.php, lines 51 and 434
      setup.php, line 44

    HOWEVER!  XRMS does not always use the mail() function to send emails.  There are at least two SMTPs classes defined which may be called through the code and there may be others.  One is in /include/classes/SMTPs/SMTPs.php and the other is in /plugins/xmtps-fix/SMTPs/SMTPs.php.

    Finally, whatever hacks you apply to the core will create difficulties upgrading your system - you will always have to merge your changes if those scripts have been updated.

    I hope this helps!


  • CharlieM

    CharlieM - 2011-02-23

    Fantastic Ivaylo, thanks a lot.

    Points noted. This is very very helpful. I'm light on using regex must get it sorted in my head. Any heads up on a good starter page for it?


  • - 2011-02-23

    You are welcome, Charlie!

    Actually, the above regex would have been better written as:


    .  As for regex, my one and only start page is almost always Google LOL



Log in to post a comment.