]>
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
, true));
78 $this->fromname
= $this->from
;
82 $this->fromname
= trim($_isso->unsanitize($this->fromname
, true));
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
), true));
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
, true));
116 $this->headers
= $this->_convert_line_breaks($this->headers
);
117 $this->headers
.= "From: \"{$this->fromname}\" <{$this->from}>\n";
118 $this->headers
.= "Return-Path: {$this->from}\n";
119 $this->headers
.= "X-Mailer: ISSO Mail Framework \$Revision$\n";
120 $this->headers
.= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
121 $this->headers
.= "Content-Transfer-Encoding: 7bit\n";
123 if (mail($this->to
, $this->subject
, $this->body
, trim($this->headers
), "-f {$this->from}"))
125 $_isso->debug("email: sent -> good");
130 $_isso->debug("email: sent -> error");
136 * Fetches the first line of a string
138 * @param str A string
140 * @return str The first line of the string
142 function _fetch_first_line($string)
144 $string = $this->_convert_line_breaks($string);
145 $broken = explode("\n", $string);
150 * Changes line breaks into one format
153 * @param str New line break (default is UNIX format)
155 * @return str Text with one type of line break
157 function _convert_line_breaks($text, $convert_to = "\n")
160 $text = str_replace(array("\r\n", "\r", "\n"), "\n", $text);
161 $text = str_replace("\n", $convert_to, $text);
166 /*=====================================================================*\
167 || ###################################################################
170 || ###################################################################
171 \*=====================================================================*/