]>
src.bluestatic.org Git - isso.git/blob - mail.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
20 $OBJECT = 'Mail Sender';
27 * This framework is a wrapper for the PHP mail function that properly
28 * sends mail with full email headers.
30 * @author Iris Studios, Inc.
31 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
39 * The message recipient's email address
46 * The subject of the message
60 * The message sender's email address
67 * The message sender's display name
74 * Additional message headers
80 * Sends an email to the specified address with the specified
81 * sender, subject, and body.
83 * @return bool Status of the message
89 if (!@ini_get('sendmail_path'))
91 $_isso->debug("email: no sendmail -> not sending");
95 $this->to
= $this->_fetch_first_line($this->to
);
96 $this->from
= $this->_fetch_first_line($this->from
);
100 $_isso->debug("email: no from -> not sending");
105 $this->from
= trim($_isso->unsanitize($this->from
, true));
108 if (!$this->fromname
)
110 $this->fromname
= $this->from
;
114 $this->fromname
= trim($_isso->unsanitize($this->fromname
, true));
119 $_isso->debug("email: no recipient -> not sending");
124 $this->to
= trim($_isso->unsanitize($this->to
));
129 $_isso->debug("email: no subject -> not sending");
134 $this->subject
= trim($_isso->unsanitize($this->_fetch_first_line($this->subject
), true));
139 $_isso->debug("email: no body -> not sending");
144 $this->body
= $this->_convert_line_breaks($this->body
);
145 $this->body
= trim($_isso->unsanitize($this->body
, true));
148 $this->headers
= $this->_convert_line_breaks($this->headers
);
149 $this->headers
.= "From: \"{$this->fromname}\" <{$this->from}>\n";
150 $this->headers
.= "Return-Path: {$this->from}\n";
151 $this->headers
.= "X-Mailer: ISSO Mail Framework \$Revision$\n";
152 $this->headers
.= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
153 $this->headers
.= "Content-Transfer-Encoding: 7bit\n";
155 if (mail($this->to
, $this->subject
, $this->body
, trim($this->headers
), "-f {$this->from}"))
157 $_isso->debug("email: sent -> good");
162 $_isso->debug("email: sent -> error");
168 * Fetches the first line of a string
170 * @param str A string
172 * @return str The first line of the string
174 function _fetch_first_line($string)
176 $string = $this->_convert_line_breaks($string);
177 $broken = explode("\n", $string);
182 * Changes line breaks into one format
185 * @param str New line break (default is UNIX format)
187 * @return str Text with one type of line break
189 function _convert_line_breaks($text, $convert_to = "\n")
192 $text = str_replace(array("\r\n", "\r", "\n"), "\n", $text);
193 $text = str_replace("\n", $convert_to, $text);
198 /*=====================================================================*\
199 || ###################################################################
202 || ###################################################################
203 \*=====================================================================*/