x

Main chapters

  1. LimeSurvey Cloud vs LimeSurvey CE
  2. LimeSurvey Cloud - Quick start guide
  3. LimeSurvey CE - Installation
  4. How to design a good survey (Guide)
  5. Getting started
  6. LimeSurvey configuration
  7. Introduction - Surveys
  8. View survey settings
  9. View survey menu
  10. View survey structure
  11. Introduction - Questions
  12. Introduction - Question Groups
  13. Introduction - Surveys - Management
  14. Survey toolbar options
  15. Multilingual survey
  16. Quick start guide - ExpressionScript
  17. Advanced features
  18. General FAQ
  19. Troubleshooting
  20. Workarounds
  21. License
  22. Version change log
  23. Plugins - Advanced
 Actions

BeforeEmail

From LimeSurvey Manual

 Hint: This features is available starting in version 4.0.0


Usage

This event can be used each time an email not related to a survey is send.

Input

The event receives the following information:

  • mailer : The mailer object
  • type : Email type : default is unknow, and deprecated usage of function is deprecated (for example for plugins not updated), partial list:
    • Token email (beforeTokenEmail)
      • invite,
      • remind,
      • register,
      • confirm,
    • Survey email (beforeSurveyEmail)
      • savesurveydetails (during survey or by admin),
      • admin_notification,
      • admin_responses,
    • Other email
      • passwordreminderadminuser,
      • addadminuser,
      • mailsendusergroup
  • subject : Email subject
  • to : Recipient(s) with format [email,name]
  • body : Email body content
  • from : Sender (From)
  • bounce : The Sender (Return-Path)
  • survey : null
  • model : null
  • updateDisable : array
  • token : null

Possible output

The following information can be set in the event:

  • updateDisable : if plugin use mailer to update other parts, allow to disable update by default action
  • subject : Email subject
  • body : Email body content
  • to : Recipient(s) in [[email,name]] format
  • from : From email and name
  • bounce : Return-Path
  • send : If true Limesurvey will send the email. Setting this to false (strict comparison) will cause Limesurvey to assume the mail has been sent by the plugin.
  • message : If send is false and action return a message : the message to be shown
  • error : If set and "send" is false, log the error as failed email attempt.

Usage of mailer

The plugin event offer as input the mailer object, then you can access and set mailer variables. For example to get the Body before you can use rawBody variables. Since mailer have a public function to do own replacement, you can update the raw body and do the replacement after.

A sample code can be :

    $mailer = $this->getEvent()->get(mailer);
    $rawBody = $mailer->rawBody;
    // Clean up code
    $oPurifier = new \CHtmlPurifier();
    $rawBody = $oPurifier->purify($rawBody);
    $body = $mailer->doReplacements($rawBody);
    $this->getEvent()->set('body',$body);

Check mailSenderToFrom core plugin for another usage of mailer to set the sender, the Response-To and the From-To. The whole class are LimeMailer and extend PHPMailer.

Example

See also