Bug #23135 ยป class.t3lib_utility_mail.php

Administrator Admin, 2010-07-08 18:22

 
1
<?php
2
/***************************************************************
3
 * Copyright notice
4
 *
5
 * (c) 2010 Tolleiv Nietsch <nietsch@aoemedia.de>
6
 * All rights reserved
7
 *
8
 * This script is part of the TYPO3 project. The TYPO3 project is
9
 * free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The GNU General Public License can be found at
15
 * http://www.gnu.org/copyleft/gpl.html.
16
 * A copy is found in the textfile GPL.txt and important notices to the license
17
 * from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

    
28
/**
29
 * Class to handle mail specific functionality
30
 *
31
 * $Id: class.t3lib_utility_mail.php 6536 2009-11-25 14:07:18Z stucki $
32
 *
33
 *
34
 * @author	 Tolleiv Nietsch <nietsch@aoemedia.de>
35
 * @package TYPO3
36
 * @subpackage t3lib
37
 */
38
final class t3lib_utility_Mail {
39

    
40
	/**
41
	 * Proxy for the PHP mail() function. Adds possibility to hook in and send the mails in a different way.
42
	 * The hook can be used by adding function to the configuration array:
43
	 * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']
44
	 *
45
	 * @param	string		Email address to send to.
46
	 * @param	string		Subject line, non-encoded. (see PHP function mail())
47
	 * @param	string		Message content, non-encoded. (see PHP function mail())
48
	 * @param	string 		Additional headers for the mail (see PHP function mail())
49
	 * @param	string		Additional flags for the sending mail tool (see PHP function mail())
50
	 * @return	boolean		Indicates whether the mail has been sent or not
51
	 * @see		PHP function mail() []
52
	 * @link	http://www.php.net/manual/en/function.mail.php
53
	 */
54
	public static function mail($to, $subject, $messageBody, $additionalHeaders = null, $additionalParameters = null) {
55
		$success = TRUE;
56
		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'])) {
57
			$parameters = array(
58
				'to' => $to,
59
				'subject' => $subject,
60
				'messageBody' => $messageBody,
61
				'additionalHeaders' => $additionalHeaders,
62
				'additionalParameters' => $additionalParameters,
63
			);
64
			$fakeThis = FALSE;
65
			foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] as $hookMethod) {
66
				$success = $success && t3lib_div::callUserFunction($hookMethod, $parameters, $fakeThis);
67
			}
68
		} else {
69
			if ($additionalParameters) {
70
				$success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
71
			} else {
72
				$success = @mail($to, $subject, $messageBody, $additionalHeaders);
73
			}
74
		}
75

    
76
		if (!$success) {
77
			t3lib_div::sysLog('Mail to "' . $to . '" could not be sent (Subject: "' . $subject . '").', 'Core', 3);
78
		}
79
		return $success;
80
	}
81
}
82
?>
    (1-1/1)