]>
src.bluestatic.org Git - isso.git/blob - mail.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 $OBJECT = 'Mail Sender';
20 * This framework is a wrapper for the PHP mail function that properly
21 * sends mail with full email headers.
23 * @author Iris Studios, Inc.
24 * @copyright Copyright ©2003 - [#]year[#], Iris Studios, Inc.
31 * Global environment variables
33 * @var to The recipient
34 * @var subject Subject of the message
35 * @var body Text/body of the email
36 * @var from The sender's email
37 * @var fromname The sender's name
38 * @var headers Additional headers
48 * Sends an email to the specified address with the specified
49 * sender, subject, and body.
51 * @return bool Status of the message
57 if (!@ini_get('sendmail_path'))
59 $_isso->debug("email: no sendmail -> not sending");
63 $this->to
= $this->_fetch_first_line($this->to
);
64 $this->from
= $this->_fetch_first_line($this->from
);
68 $_isso->debug("email: no from -> not sending");
73 $this->from
= trim($_isso->unsanitize($this->from
));
78 $this->fromname
= $this->from
;
82 $this->fromname
= trim($_isso->unsanitize($this->fromname
));
87 $_isso->debug("email: no recipient -> not sending");
92 $this->to
= trim($_isso->unsanitize($this->to
));
97 $_isso->debug("email: no subject -> not sending");
102 $this->subject
= trim($_isso->unsanitize($this->_fetch_first_line($this->subject
)));
107 $_isso->debug("email: no body -> not sending");
112 $this->body
= $this->_convert_line_breaks($this->body
);
113 $this->body
= trim($_isso->unsanitize($this->body
));
116 $headers = $this->_convert_line_breaks($this->headers
, "\n");
117 $headers .= "From \"{$this->fromname}\" <{$this->from}>\n";
118 $headers .= "Return-Path: {$this->from}\n";
119 $headers .= "X-Mailer: ISSO Mail Framework \$Revision$\n";
120 $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
121 $headers .= "Content-Transfer-Encoding: 7bit\n";
122 $headers = trim($headers);
124 if (mail($this->to
, $this->subject
, $this->body
, $headers, "-f {$this->from}"))
126 $_isso->debug("email: sent -> good");
131 $_isso->debug("email: sent -> error");
137 * Fetches the first line of a string
139 * @param str A string
141 * @return str The first line of the string
143 function _fetch_first_line($string)
145 $string = $this->_convert_line_breaks($string);
146 $broken = explode("\r\n", $string);
151 * Changes line breaks into one format
154 * @param str New line break (default is Windows DOS format)
156 * @return str Text with one type of line break
158 function _convert_line_breaks($text, $convert_to = "\r\n")
160 return preg_replace("#(\r|\n|\r\n)#s", $convert_to, trim($text));
164 /*=====================================================================*\
165 || ###################################################################
168 || ###################################################################
169 \*=====================================================================*/