2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
29 $OBJECT = 'Mail Sender';
36 * This framework is a wrapper for the PHP mail function that properly
37 * sends mail with full email headers.
39 * @author Iris Studios, Inc.
40 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
48 * The message recipient's email address
55 * The subject of the message
69 * The message sender's email address
76 * The message sender's display name
83 * Additional message headers
89 * Sends an email to the specified address with the specified
90 * sender, subject, and body.
92 * @return bool Status of the message
98 if (!@ini_get('sendmail_path'))
100 $_isso->debug("email: no sendmail -> not sending");
104 $this->to
= $this->_fetch_first_line($this->to
);
105 $this->from
= $this->_fetch_first_line($this->from
);
109 $_isso->debug("email: no from -> not sending");
114 $this->from
= trim($_isso->unsanitize($this->from
, true
));
117 if (!$this->fromname
)
119 $this->fromname
= $this->from
;
123 $this->fromname
= trim($_isso->unsanitize($this->fromname
, true
));
128 $_isso->debug("email: no recipient -> not sending");
133 $this->to
= trim($_isso->unsanitize($this->to
));
138 $_isso->debug("email: no subject -> not sending");
143 $this->subject
= trim($_isso->unsanitize($this->_fetch_first_line($this->subject
), true
));
148 $_isso->debug("email: no body -> not sending");
153 $this->body
= $this->_convert_line_breaks($this->body
);
154 $this->body
= trim($_isso->unsanitize($this->body
, true
));
157 $this->headers
= $this->_convert_line_breaks($this->headers
);
158 $this->headers
.= "From: \"{$this->fromname}\" <{$this->from}>\n";
159 $this->headers
.= "Return-Path: {$this->from}\n";
160 $this->headers
.= "X-Mailer: ISSO Mail Framework \$Revision$\n";
161 $this->headers
.= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
162 $this->headers
.= "Content-Transfer-Encoding: 7bit\n";
164 if (mail($this->to
, $this->subject
, $this->body
, trim($this->headers
), "-f {$this->from}"))
166 $_isso->debug("email: sent -> good");
171 $_isso->debug("email: sent -> error");
177 * Fetches the first line of a string
179 * @param str A string
181 * @return str The first line of the string
183 function _fetch_first_line($string)
185 $string = $this->_convert_line_breaks($string);
186 $broken = explode("\n", $string);
191 * Changes line breaks into one format
194 * @param str New line break (default is UNIX format)
196 * @return str Text with one type of line break
198 function _convert_line_breaks($text, $convert_to = "\n")
201 $text = str_replace(array("\r\n", "\r", "\n"), "\n", $text);
202 $text = str_replace("\n", $convert_to, $text);
207 /*=====================================================================*\
208 || ###################################################################
211 || ###################################################################
212 \*=====================================================================*/