Sending Emails
Overview
Seagull provides the class SGL_Emailer for sending emails. It's a wrapper around PEAR::mail so there are quite a few options available.
In the modules provided with Seagull there are a number of examples and variations of sending email with SGL_Emailer.
Example
Sending an HTML email:
$options = array(
'toEmail' => $conf['email']['info'],
'toRealName' => 'Admin',
'fromEmail' => $oContact->email,
'fromRealName' => $contacterName,
'replyTo' => $oContact->email,
'subject' => 'Contact Enquiry from ' . $conf['site']['name'],
'type' => $oContact->type,
'body' => $oContact->comment,
'template' => SGL_MOD_DIR . '/' . $this->module . '/templates/' .
$_SESSION['prefs']['theme'] . '/email_contact_us.php',
);
$message = & new SGL_Emailer($options);
$message->prepare();
return $message->send();
Adding multiple attachments to a single email
- requires >= Seagull 0.6.3
You can add multiple attachments to a single email. When passing the $options 'filepath' parameter as an array, each entry in the array will be added as a separate attachment. When the $options parameter 'mimetype' gets passed as an array containing the same number of values as 'filepath', each attachment gets a unique mimetype, otherwise the same mimetype for all attachments is used.
In this example two attachments have their own mimetype:
$options = array(
...
'filepath' => array('path/to/gif','path/to/jpg'),
'mimetype' => array('image/gif','image/jpeg'),
);
In this example all attachments get the same mimetype:
$options = array(
...
'filepath' => array('path/to/file1','path/to/file2'),
'mimetype' => 'text/plain',
);
