ImpressPages has ipSendEmail function for sending e-mail messages from your plugins. Usage of this function for all email activities is recommended because:
- data is escaped to prevent spam being send injecting code in recipient addres
- you can easily controll how many emails per hour can be send on your server
- you can see all email activity in administration panel
All emails sent by ipSendEmail are sent immediatelly or placed to the queue for processing later if hourly limit is reached. Default hourly limit is up to 100 emails per hour.
Send an e-mail
<?php ipSendEmail("email@example.com", "Sender name", "firstname.lastname@example.org", "Recipient name", "Email subject", "<div>Hello John Smith, </div><div>This is a test e-mail.</div>");
Send non-urgent e-mail
When you send a newsletter to thousands of recipients, you can easily exhaust your hourly limit. Mark these emails as non urgent by adding false as seventh parameter. This will instruct email queue to leave 20% of throughput. And send the rest of the emails later on.
<?php ipSendEmail( "email@example.com", "My Website", "firstname.lastname@example.org", "John Smith", "Test e-mail", "<div>This is non-urgent e-mail message.</div>", false );
Send an e-mail in plain text
<?php ipSendEmail( "email@example.com", "My Website", "firstname.lastname@example.org", "John Smith", "Newsletter test", "Hello John Smith,\r\nThis is a test newsletter.", true, false );
Send an e-mail with file attachments
To attach files to your e-mail message, provide function arguments with an array of file names, as in example below:
<?php $files = array(ipFile('file/tmp/readme.txt'), ipFile('file/tmp/picture.jpg')); ipSendEmail( "email@example.com", "My Website", "firstname.lastname@example.org", "John Smith", "Test e-mail with attachment", "See the files attached.", true, true, $files );
Get website's email
Use ipEmailTemplate function to generate email looking the same as all other emails on the system. You can pass title, signature and footer variables alongside the content.
$emailData = array( 'content' => $content ); $emailHtml = ipEmailTemplate($emailData);
This function uses Ip/Internal/Config/view/email.php view to render the HTML. You can override it in your theme and all emails sent by ImpressPages will have a new look.