Open-Source PHP Framework - Designed for rapid development of performance-oriented scalable applications

/mvc/components/email

[return to app]
1 <?php
2
/**
3  * Email-sending functionality
4  */
5
class emailComponent {
6     
/**
7      * Sends an email.
8      *
9      * Required argument keys are: to, from, subject, body
10      * Optional keys are: fromName, (boolean) html, (array) headers
11      *
12      * @param array $args
13      * @return boolean Success status sending email
14      */
15     
public function sendEmail(array $args) {
16         
extract($args);
17
18         
$headers['from'] = 'From: ';
19         if (isset(
$fromName)) {
20             
$headers['from'] .= '"' $fromName '" ';
21         }
22         
$headers['from'] .= '<' $from ">\r\n";
23         
ini_set('sendmail_from'$from);
24
25         if (isset(
$html) && $html) {
26             
$headers['html'] = "Content-type: text/html; charset=iso-8859-1\r\n";
27         }
28         return 
mail($to$subject$bodyimplode($headers), '-f' $from);
29     }
30 }