Project

General

Profile

« Previous | Next » 

Revision 386

Added by Matthias almost 18 years ago

Added phpmailer class (thanks to doc)

View differences:

class.wb.php
36 36

  
37 37
require_once(WB_PATH.'/framework/class.database.php');
38 38

  
39
// Include new wbmailer class (subclass of PHPmailer)
40
require_once(WB_PATH."/framework/class.wbmailer.php");
41

  
39 42
class wb
40 43
{
41 44
	// General initialization function 
......
231 234
		}
232 235
		exit();
233 236
	}
237

  
234 238
	// Validate send email
235 239
	function mail($fromaddress, $toaddress, $subject, $message) {
236 240
		$fromaddress = preg_replace('/[\r\n]/', '', $fromaddress);
237 241
		$toaddress = preg_replace('/[\r\n]/', '', $toaddress);
238 242
		$subject = preg_replace('/[\r\n]/', '', $subject);
243
		$message = preg_replace('/[\r\n]/', '<br \>', $message);
244
		
245
		/* 
246
		SOME PROVIDERS (LIKE GMX) DOES NOT DELIVER MAILS VIA DEFAULT PHP mail() FUNCTION AS
247
		THIS FUNCTION DOES NOT PROVIDE SMTP AUTHENTIFICATION
248
		NEW WBMAILER CLASS IS ABLE TO SEND OUT MESSAGES USING SMTP WHICH RESOLVE THESE ISSUE
249
		
250
		NOTE:
251
		To use SMTP for sending out mails, you have to specify the SMTP host of your domain
252
		via the variable "WBMAILER_SMTP_HOST" in the "config.php" file
253
		If variable is not defined, the WBMAILER class uses the PHP mail() function per default
254
		
255
		the mail header is automatically created by PHPMailer and therefore commented out
256
		UPDATE INTRODUCED BY DOC (C. SOMMER, 22. October 2006)
257
		*/ 
258
		
259
		/* 
239 260
		if ($fromaddress=='') {
240 261
			$fromaddress = SERVER_EMAIL;
241 262
		}
263
		
242 264
		if(defined('DEFAULT_CHARSET')) { 
243 265
			$charset = DEFAULT_CHARSET; 
244 266
		} else {
245 267
			$charset='utf-8';
246 268
		}
269
		
247 270
		$headers  = "MIME-Version: 1.0\n";
248 271
		$headers .= "Content-type: text/plain; charset=".$charset."\n";
249 272
		$headers .= "X-Priority: 3\n";
......
253 276
		$headers .= "Return-Path: ".$fromaddress."\n";
254 277
		$headers .= "Reply-To: ".$fromaddress."\n";
255 278
		$headers .= "\n"; // extra empty line needed??
279
		
256 280
		if (OPERATING_SYSTEM=='windows') {
257
			str_replace("\n","\r\n",$headers);
281
			//str_replace("\n","\r\n",$headers);
258 282
			str_replace("\n","\r\n",$message);
259 283
		}	
284
		
260 285
		if(mail($toaddress, $subject, $message, $headers)) {
261 286
			return true;
262 287
		} else {
263 288
			return false;
264 289
		}
290
		*/
291
		
292
		// create PHPMailer object and define default settings
293
		$myMail = new wbmailer();
294
      
295
		// set user defined from address
296
		if ($fromaddress!='') {
297
			$myMail->From = $fromaddress;                           // FROM:
298
			$myMail->AddReplyTo($fromaddress);                      // REPLY TO:
299
		}
300
		
301
		// define recepient and information to send out
302
		$myMail->AddAddress($toaddress);                            // TO:
303
		$myMail->Subject = $subject;                                // SUBJECT
304
		$myMail->Body = $message;                                   // CONTENT (HTML)
305
		$myMail->AltBody = strip_tags($message);                    // CONTENT (TEXT)
306
		
307
		// check if there are any send mail errors, otherwise say successful
308
		if (!$myMail->Send()) {
309
			return false;
310
		} else {
311
			return true;
312
		}
265 313
	}
266 314

  
267 315
}

Also available in: Unified diff