Send e-mails using email queue
ImpressPages CMS has an email queue which carry all emails sent via ImpressPages CMS. It is good to use this queue in your plugin. Then you don't need to worry about correct headers, how to add file attachment or emails limit on shared server. Email queue will handle all of that for you and store copy of email in log (Administrator -> Email queue).
This is how you should send email on ImpressPages CMS:
<?php $emailQueue = new \Modules\administrator\email_queue\Module(); $emailQueue->addEmail($from, $fromName, $to, $toName, $subject, $content, $immediate, $html, $files = null); $emailQueue->send(); ?>
- $from - sender email
- $fromName - sender name
- $to - recipient email
- $toName - recipient name
- $content - email content. HTML or plane text.
- $immediate - true if email should be sent immediately
- $html - true if $content is HTML
- $files - array of paths to files to be attached. This could be temporary directory. Script will cache the file in the database.
Use email template
ImpressPages CMS has default email layout which contains greeting and signature below the email. Here is an example how to use it:
<?php global $parametersMod; $content = '<p>Text needed to be send.</p>' $websiteName = $parametersMod->getValue('standard', 'configuration', 'main_parameters', 'name'); $websiteEmail = $parametersMod->getValue('standard', 'configuration', 'main_parameters', 'email'); $emailData = array( 'content' => $content, 'name' => $websiteName, 'email' => $websiteEmail ); $content = \Ip\View::create(BASE_DIR.MODULE_DIR.'standard/configuration/view/email.php', $emailData)->render(); //put this $content variable as $content to above described addEmail function