Project

General

Profile

« Previous | Next » 

Revision 1386

Added by Dietmar almost 14 years ago

update headerinfos

View differences:

class.wbmailer.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27

  
28
wbmailer class
29

  
30
This class is a subclass of the PHPMailer class and replaces the mail() function of PHP
31

  
32
*/
33

  
34
// Include PHPMailer class
35
require_once(WB_PATH."/include/phpmailer/class.phpmailer.php");
36

  
37
class wbmailer extends PHPMailer 
38
{
39
	// new websitebaker mailer class (subset of PHPMailer class)
40
	// setting default values 
41

  
42
	function wbmailer() {
43
		// set mailer defaults (PHP mail function)
44
		$db_wbmailer_routine = "phpmail";
45
		$db_wbmailer_smtp_host = "";
46
		$db_wbmailer_default_sendername = "WB Mailer";
47
		$db_server_email = SERVER_EMAIL;
48

  
49
		// get mailer settings from database
50
		$database = new database();
51
		$query = "SELECT * FROM " .TABLE_PREFIX. "settings";
52
		$results = $database->query($query);
53
		while($setting = $results->fetchRow()) {
54
			if ($setting['name'] == "wbmailer_routine") { $db_wbmailer_routine = $setting['value']; }
55
			if ($setting['name'] == "wbmailer_smtp_host") { $db_wbmailer_smtp_host = $setting['value']; }
56
			if ($setting['name'] == "wbmailer_smtp_auth") { $db_wbmailer_smtp_auth = (bool)$setting['value']; }
57
			if ($setting['name'] == "wbmailer_smtp_username") { $db_wbmailer_smtp_username = $setting['value']; }
58
			if ($setting['name'] == "wbmailer_smtp_password") { $db_wbmailer_smtp_password = $setting['value']; }
59
			if ($setting['name'] == "wbmailer_default_sendername") { $db_wbmailer_default_sendername = $setting['value']; }
60
			if ($setting['name'] == "server_email") { $db_server_email = $setting['value']; }
61
		}
62

  
63
		// set method to send out emails
64
		if($db_wbmailer_routine == "smtp" AND strlen($db_wbmailer_smtp_host) > 5) {
65
			// use SMTP for all outgoing mails send by Website Baker
66
			$this->IsSMTP();                                            
67
			$this->Host = $db_wbmailer_smtp_host;
68
			// check if SMTP authentification is required
69
			if ($db_wbmailer_smtp_auth == "true" && strlen($db_wbmailer_smtp_username) > 1 && strlen($db_wbmailer_smtp_password) > 1) {
70
				// use SMTP authentification
71
				$this->SMTPAuth = true;     	  								// enable SMTP authentification
72
				$this->Username = $db_wbmailer_smtp_username;  	// set SMTP username
73
				$this->Password = $db_wbmailer_smtp_password;	  // set SMTP password
74
			}
75
		} else {
76
			// use PHP mail() function for outgoing mails send by Website Baker
77
			$this->IsMail();
78
		}
79

  
80
		// set language file for PHPMailer error messages
81
		if(defined("LANGUAGE")) {
82
			$this->SetLanguage(strtolower(LANGUAGE),"language");    // english default (also used if file is missing)
83
		}
84

  
85
		// set default charset
86
		if(defined('DEFAULT_CHARSET')) { 
87
			$this->CharSet = DEFAULT_CHARSET; 
88
		} else {
89
			$this->CharSet='utf-8';
90
		}
91

  
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
/*
27

  
28
wbmailer class
29

  
30
This class is a subclass of the PHPMailer class and replaces the mail() function of PHP
31

  
32
*/
33

  
34
// Include PHPMailer class
35
require_once(WB_PATH."/include/phpmailer/class.phpmailer.php");
36

  
37
class wbmailer extends PHPMailer 
38
{
39
	// new websitebaker mailer class (subset of PHPMailer class)
40
	// setting default values 
41

  
42
	function wbmailer() {
43
		global $database;
44
		// set mailer defaults (PHP mail function)
45
		$db_wbmailer_routine = "phpmail";
46
		$db_wbmailer_smtp_host = "";
47
		$db_wbmailer_default_sendername = "WB Mailer";
48
		$db_server_email = SERVER_EMAIL;
49

  
50
		// get mailer settings from database
51
		// $database = new database();
52
		$query = "SELECT * FROM " .TABLE_PREFIX. "settings";
53
		$results = $database->query($query);
54
		while($setting = $results->fetchRow()) {
55
			if ($setting['name'] == "wbmailer_routine") { $db_wbmailer_routine = $setting['value']; }
56
			if ($setting['name'] == "wbmailer_smtp_host") { $db_wbmailer_smtp_host = $setting['value']; }
57
			if ($setting['name'] == "wbmailer_smtp_auth") { $db_wbmailer_smtp_auth = (bool)$setting['value']; }
58
			if ($setting['name'] == "wbmailer_smtp_username") { $db_wbmailer_smtp_username = $setting['value']; }
59
			if ($setting['name'] == "wbmailer_smtp_password") { $db_wbmailer_smtp_password = $setting['value']; }
60
			if ($setting['name'] == "wbmailer_default_sendername") { $db_wbmailer_default_sendername = $setting['value']; }
61
			if ($setting['name'] == "server_email") { $db_server_email = $setting['value']; }
62
		}
63

  
64
		// set method to send out emails
65
		if($db_wbmailer_routine == "smtp" AND strlen($db_wbmailer_smtp_host) > 5) {
66
			// use SMTP for all outgoing mails send by Website Baker
67
			$this->IsSMTP();                                            
68
			$this->Host = $db_wbmailer_smtp_host;
69
			// check if SMTP authentification is required
70
			if ($db_wbmailer_smtp_auth == "true" && strlen($db_wbmailer_smtp_username) > 1 && strlen($db_wbmailer_smtp_password) > 1) {
71
				// use SMTP authentification
72
				$this->SMTPAuth = true;     	  								// enable SMTP authentification
73
				$this->Username = $db_wbmailer_smtp_username;  	// set SMTP username
74
				$this->Password = $db_wbmailer_smtp_password;	  // set SMTP password
75
			}
76
		} else {
77
			// use PHP mail() function for outgoing mails send by Website Baker
78
			$this->IsMail();
79
		}
80

  
81
		// set language file for PHPMailer error messages
82
		if(defined("LANGUAGE")) {
83
			$this->SetLanguage(strtolower(LANGUAGE),"language");    // english default (also used if file is missing)
84
		}
85

  
86
		// set default charset
87
		if(defined('DEFAULT_CHARSET')) { 
88
			$this->CharSet = DEFAULT_CHARSET; 
89
		} else {
90
			$this->CharSet='utf-8';
91
		}
92

  
92 93
		// set default sender name
93
		if($this->FromName == 'Root User') {

94
			if(isset($_SESSION['DISPLAY_NAME'])) {

95
				$this->FromName = $_SESSION['DISPLAY_NAME'];            // FROM NAME: display name of user logged in

96
			} else {

97
				$this->FromName = $db_wbmailer_default_sendername;			// FROM NAME: set default name

98
			}

94
		if($this->FromName == 'Root User') {
95
			if(isset($_SESSION['DISPLAY_NAME'])) {
96
				$this->FromName = $_SESSION['DISPLAY_NAME'];            // FROM NAME: display name of user logged in
97
			} else {
98
				$this->FromName = $db_wbmailer_default_sendername;			// FROM NAME: set default name
99
			}
99 100
		}
100

  
101
		/* 

102
			some mail provider (lets say mail.com) reject mails send out by foreign mail 

103
			relays but using the providers domain in the from mail address (e.g. myname@mail.com)

104
		*/

105
		$this->From = $db_server_email;                           // FROM MAIL: (server mail)

106

  
107
		// set default mail formats

108
		$this->IsHTML(true);                                        

109
		$this->WordWrap = 80;                                       

110
		$this->Timeout = 30;

111
	}

112
}

113

  
101

  
102
		/* 
103
			some mail provider (lets say mail.com) reject mails send out by foreign mail 
104
			relays but using the providers domain in the from mail address (e.g. myname@mail.com)
105
		*/
106
		$this->From = $db_server_email;                           // FROM MAIL: (server mail)
107

  
108
		// set default mail formats
109
		$this->IsHTML(true);                                        
110
		$this->WordWrap = 80;                                       
111
		$this->Timeout = 30;
112
	}
113
}
114

  
114 115
?>

Also available in: Unified diff