15998.diff

Administrator Admin, 2010-10-16 19:24

Download (11.4 KB)

View differences:

t3lib/config_default.php (Arbeitskopie)
352 352
		'versionNumberInFilename' => 'querystring',	// String: embed,querystring,''. Allows to automatically include a version number (timestamp of the file) to referred CSS and JS filenames on the rendered page. This will make browsers and proxies reload the files if they change (thus avoiding caching issues). Set to 'embed' will have the timestamp embedded in the filename, ie. filename.1269312081.js. IMPORTANT: 'embed' requires extra .htaccess rules to work (please refer to misc/advanced.htaccess or the _.htaccess file from the dummy package)<p>Set to 'querystring' (default setting) to append the version number as a query parameter (doesn't require mod_rewrite). Set to '' will turn this functionality off (behaves like TYPO3 &lt; v4.4).</p>
353 353
		'XCLASS' => array(),					// See 'Inside TYPO3' document for more information.
354 354
	),
355
	'MAIL' => array(		// Mail configurations to tune how t3lib_mail classes will send their mails.
356
		'transport' => 'mail',					// <p>String:</p><dl><dt>mail</dt><dd>Sends messages by delegating to PHP's internal mail() function. No further settings required. This is the most unreliable option. If you are serious about sending mails, consider using "smtp" or "sendmail".</dd><dt>smtp</dt><dd>Sends messages over the (standardized) Simple Message Transfer Protocol. It can deal with encryption and authentication. Most flexible option, requires a mail server and configurations in transport_smtp_* settings below. Works the same on Windows, Unix and MacOS.</dd><dt>sendmail</dt><dd>Sends messages by communicating with a locally installed MTA – such as sendmail. See setting transport_sendmail_command bellow.<dd></dl>
357
		'transport_smtp_server' => 'localhost:25',			// String: <em>only with transport=smtp</em>: &lt;server:port> of mailserver to connect to. &lt;port> defaults to "25".
358
		'transport_smtp_encrypt' => FALSE,		// Boolean: <em>only with transport=smtp</em>: Connect to the server using encryption and TLS. Requires openssl library.
359
		'transport_smtp_username' => '',		// String: <em>only with transport=smtp</em>: If your SMTP server requires authentication, enter your username here.
360
		'transport_smtp_password' => '',		// String: <em>only with transport=smtp</em>: If your SMTP server requires authentication, enter your password here.
361
		'transport_sendmail_command' => '/usr/sbin/sendmail -bs',	// String: <em>only with transport=sendmail</em>: The command to call to send a mail locally. The default works on most modern UNIX based mail server (sendmail, postfix, exim)
362
	),
355 363
	'MODS' => array(		// Backend Module Configuration (obsolete, make extension instead)
356 364
	),
357 365
	'USER' => array(		// Here you may define your own setup-vars for use in your include-scripts. (obsolete, make extension instead)
t3lib/core_autoload.php (Arbeitskopie)
140 140
	't3lib_spritemanager_spriteicongenerator' => PATH_t3lib . 'interfaces/interface.t3lib_spritemanager_spriteicongenerator.php',
141 141
	't3lib_spritemanager_simplehandler' => PATH_t3lib . 'spritemanager/class.t3lib_spritemanager_simplehandler.php',
142 142
	't3lib_extjs_extdirectdebug' => PATH_t3lib . 'extjs/class.t3lib_extjs_extdirectdebug.php',
143
	't3lib_mail_message' => PATH_t3lib . 'mail/class.t3lib_mail_message.php',
144
	't3lib_mail_mailer' => PATH_t3lib . 'mail/class.t3lib_mail_mailer.php',
143 145
);
144 146

  
145 147
$tslibClasses = require(PATH_typo3 . 'sysext/cms/ext_autoload.php');
t3lib/mail/class.t3lib_mail_mailer.php (Revision 0)
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2010 Ernesto Baschny <ernst@cron-it.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
	// Make sure Swift's auto-loader is registered
29
require_once(PATH_typo3 . 'contrib/swiftmailer/swift_required.php');
30

  
31

  
32
/**
33
 * Adapter for Swift_Mailer to be used by TYPO3 extensions.
34
 *
35
 * This will use the setting in TYPO3_CONF_VARS to choose the correct transport
36
 * for it to work out-of-the-box.
37
 *
38
 * $Id$
39
 *
40
 * @author	Ernesto Baschny <ernst@cron-it.de>
41
 * @package TYPO3
42
 * @subpackage t3lib
43
 */
44
class t3lib_mail_mailer extends Swift_Mailer {
45

  
46
	/**
47
	 * @var Swift_Transport
48
	 */
49
	protected $transport;
50

  
51
	/**
52
	 * When constructing, also initializes the Swift_Transport like configured
53
	 *
54
	 * @throws t3lib_exception
55
	 */
56
	public function __construct() {
57
		try {
58
			$this->initializeTransport();
59
		} catch (Exception $e) {
60
			throw new t3lib_exception($e->getMessage());
61
		}
62
		parent::__construct($this->transport);
63
	}
64

  
65
	/**
66
	 * Prepares a transport using the TYPO3_CONF_VARS configuration
67
	 *
68
	 * Used options:
69
	 * $TYPO3_CONF_VARS['MAIL']['transport'] = 'smtp' | 'sendmail' | 'mail'
70
	 *
71
	 * $TYPO3_CONF_VARS['MAIL']['transport_smtp_server'] = 'smtp.example.org';
72
	 * $TYPO3_CONF_VARS['MAIL']['transport_smtp_port'] = '25';
73
	 * $TYPO3_CONF_VARS['MAIL']['transport_smtp_encrypt'] = FALSE; # requires openssl in PHP
74
	 * $TYPO3_CONF_VARS['MAIL']['transport_smtp_username'] = 'username';
75
	 * $TYPO3_CONF_VARS['MAIL']['transport_smtp_password'] = 'password';
76
	 *
77
	 * $TYPO3_CONF_VARS['MAIL']['transport_sendmail_command'] = '/usr/sbin/sendmail -bs'
78
	 *
79
	 * @throws Exception
80
	 */
81
	private function initializeTransport() {
82
		$mailSettings = $GLOBALS['TYPO3_CONF_VARS']['MAIL'];
83
		switch ($mailSettings['transport']) {
84

  
85
			case 'smtp':
86
					// Get settings to be used when constructing the transport object
87
				list($host, $port) = split(':', $mailSettings['transport_smtp_server']);
88
				if ($host === '') {
89
					throw new t3lib_exception('$TYPO3_CONF_VARS[\'MAIL\'][\'transport_smtp_server\'] needs to be set when transport is set to "smtp"');
90
				}
91
				if ($port === '') {
92
					$port = '25';
93
				}
94
				$useEncryption = ( $mailSettings['transport_smtp_encrypt'] ? TRUE : FALSE);
95

  
96
				// Create our transport
97
				$this->transport = Swift_SmtpTransport::newInstance($host, $port, $useEncryption);
98

  
99
					// Need authentication?
100
				$username = $mailSettings['transport_smtp_username'];
101
				if ($username !== '') {
102
					$this->transport->setUsername($username);
103
				}
104
				$password = $mailSettings['transport_smtp_password'];
105
				if ($password !== '') {
106
					$this->transport->setPassword($password);
107
				}
108
				break;
109

  
110
			case 'sendmail':
111
				$sendmailCommand = $mailSettings['transport_sendmail_command'];
112
				if ($sendmailCommand === '') {
113
					throw new t3lib_exception('$TYPO3_CONF_VARS[\'MAIL\'][\'transport_sendmail_command\'] needs to be set when transport is set to "sendmail"');
114
				}
115
					// Create our transport
116
				$this->transport = Swift_SendmailTransport::newInstance($sendmailCommand);
117
				break;
118

  
119
			case 'mail':
120
			default:
121
					// Create the transport, no configuration required
122
				$this->transport = Swift_MailTransport::newInstance();
123
				break;
124
		}
125
		return;
126
	}
127

  
128
}
129

  
130
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_mail_mailer.php'])	{
131
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_mail_mailer.php']);
132
}
133

  
134
?>
t3lib/mail/class.t3lib_mail_message.php (Revision 0)
1
<?php
2
/***************************************************************
3
*  Copyright notice
4
*
5
*  (c) 2010 Ernesto Baschny <ernst@cron-it.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
require_once(PATH_typo3.'contrib/swiftmailer/swift_required.php');
29

  
30

  
31
/**
32
 * Adapter for Swift_Mailer to be used by TYPO3 extensions
33
 *
34
 * $Id$
35
 *
36
 * @author	Ernesto Baschny <ernst@cron-it.de>
37
 * @package TYPO3
38
 * @subpackage t3lib
39
 */
40
class t3lib_mail_message extends Swift_Message {
41

  
42
	/**
43
	 * @var t3lib_mail_mailer
44
	 */
45
	var $mailer;
46

  
47
	/**
48
	 * True if the message has been sent.
49
	 * @var boolean
50
	 */
51
	var $sent = FALSE;
52

  
53
	/**
54
	 * Holds the failed recipients after the message has been sent
55
	 * @var array
56
	 */
57
	var $failedRecipients = array();
58

  
59
	/**
60
	 *
61
	 * @return void
62
	 */
63
	private function initializeMailer() {
64
		$this->mailer = t3lib_div::makeInstance('t3lib_mail_mailer');
65
	}
66

  
67
	/**
68
	 * Sends the message.
69
	 *
70
	 * @return integer the number of recipients who were accepted for delivery
71
	 * @author Karsten Dambekalns <karsten@typo3.org>
72
	 */
73
	public function send() {
74
		$this->initializeMailer();
75
		$this->sent = TRUE;
76
		return $this->mailer->send($this, &$this->failedRecipients);
77
	}
78

  
79
	/**
80
	 * Checks whether the message has been sent.
81
	 *
82
	 * @return boolean
83
	 * @author Karsten Dambekalns <karsten@typo3.org>
84
	 */
85
	public function isSent() {
86
		return $this->sent;
87
	}
88

  
89
	/**
90
	 * Returns the recipients for which the mail was not accepted for delivery.
91
	 *
92
	 * @return array the recipients who were not accepted for delivery
93
	 * @author Karsten Dambekalns <karsten@typo3.org>
94
	 */
95
	public function getFailedRecipients() {
96
		return $this->failedRecipients;
97
	}
98

  
99
}
100

  
101
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_mail_message.php'])	{
102
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_mail_message.php']);
103
}
104

  
105
?>