Customising the Mail Functions

Help
CharlieM
2011-02-17
2013-04-26
  • 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:
    '-fsomeuser@mydomain.co.uk'

    EG:-

    mail($recipient, $subject, $message, $headers, '-fsomeuser@mydomain.co.uk')

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

     
  • 360team.ca
    360team.ca
    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?

    Cheers,
    Ivaylo

     
  • CharlieM
    CharlieM
    2011-02-17

    Ivaylo

    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.

    Charlie

     
  • CharlieM
    CharlieM
    2011-02-22

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

     
  • 360team.ca
    360team.ca
    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

    mail[\s]*[(]
    

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

    /xrms/reports
      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
    /plugins/webform
      new-form.php, lines 51 and 434
    /plugin/account_lockout
      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!

    Cheers,
    Ivaylo

     
  • 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?

    Charlie

     
  • 360team.ca
    360team.ca
    2011-02-23

    You are welcome, Charlie!

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

    [\s]mail[\s]*[(]
    

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

    Cheers,
    Ivaylo