We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15566
    • 73 Posts
    Revo 2.2.5

    I have looked everywhere (forums, Google, blogs etc.) for pointers and can't get my plugin to work. It is so simple I am not sure what it can be:

    $e = $modx->event->name;
    mail("[email protected]", "TEST", $e);
    return;
    


    Events:
    OnBeforeDocFormSave
    OnDocFormSave
    OnDocPublished
    OnDocUnPublished

    What I am expecting is an email to be sent to me when a doc is saved, published or unpublished. Nothing is happening at all. Eventually this script will create a zip every time a document is saved or updated but I am falling at the first hurdle.
    • Hi, looking in another plugin I found this code to send email:

              $modx->getService('mail', 'mail.modPHPMailer');
              $modx->mail->set(modMail::MAIL_BODY, $_msg);
              $modx->mail->set(modMail::MAIL_FROM, $_from);
              $modx->mail->set(modMail::MAIL_FROM_NAME, $_fromName);
              $modx->mail->set(modMail::MAIL_SENDER, $_sender);
              $modx->mail->set(modMail::MAIL_SUBJECT, $_subject);
              $modx->mail->address('to', $email, $name);
              $modx->mail->address('reply-to',$_reply);
              $modx->mail->setHTML(true);
              $sent = $modx->mail->send();
              $modx->mail->reset();


      eventually you can get "$_from" and other field from system settings
        TilliLab | MODX Ambassador
        website
        • TilliLab | MODX Ambassador
          website
          • 15566
          • 73 Posts
          Thanks for that. I did have a feeling that MODx was blocking the mail() function. Hopefully I should be able to get the plugin written now I know it's running.
            • 3749
            • 24,544 Posts
            It's quite possible that your host is blocking the mail() function. Many do.

            You can install the QuickEmail extra for a quick check and some diagnostics.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting