Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-52780

Better email debugging with X-Moodle-Originating-Script header

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Make sure that the php ini setting for script headers is on:

      http://php.net/manual/en/mail.configuration.php#ini.mail.add-x-header

      1) Send an email from somewhere in moodle that uses email_to_user
      2) Send an email from somewhere in moodle that uses the message API (message_send)

      In both cases check the received email and you should get a header that looks like this:

      X-Moodle-Originating-Script: http://moodle.local => silverbirch:/var/www/vanilla-moodle/admin/tool/email/email.php:83

      as well as the normal header that php adds:

      X-PHP-Originating-Script: 1001:class.phpmailer.php

      Show
      Make sure that the php ini setting for script headers is on: http://php.net/manual/en/mail.configuration.php#ini.mail.add-x-header 1) Send an email from somewhere in moodle that uses email_to_user 2) Send an email from somewhere in moodle that uses the message API (message_send) In both cases check the received email and you should get a header that looks like this: X-Moodle-Originating-Script: http://moodle.local => silverbirch:/var/www/vanilla-moodle/admin/tool/email/email.php:83 as well as the normal header that php adds: X-PHP-Originating-Script: 1001:class.phpmailer.php
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull Master Branch:
      MDL-52780-mailoriginscript

      Description

      When you have a large number of moodles running in a range of different setups, sometimes it can be hard to know what script is sending out emails when you are trying to debug stuff. Some use cases I've seen in my travels:

      a) a moodle is misconfgured and looks like it is actually coming from another moodle instance.
      b) multiple moodles on the same box which have the same from address (eg same support email)
      c) a cluster where a single node is different to the rest
      d) cloned environments sending emails that shouldn't (ie the hostname makes this very easy to track down)

      There is a php ini var (mail.add-x-header) which is conceptually what we want but in practice it is practically useless because it only adds the basename and not the full path. To help with all the use cases above we need the wwwhost it's come from, and that servers hostname and the exact moodle script which fired it off (and not simply the phpmailer class which doesn't tell you anything).

      See: http://php.net/manual/en/mail.configuration.php#ini.mail.add-x-header

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                23/May/16