Project

General

Profile

« Previous | Next » 

Revision 295

Added by stefan almost 19 years ago

John: Changed the e-mail validation code and added a mail function to class wb.

View differences:

trunk/wb/framework/class.wb.php
189 189

  
190 190
	// Validate supplied email address
191 191
	function validate_email($email) {
192
		if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
192
		if(eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $email)) {
193 193
			return true;
194 194
		} else {
195 195
			return false;
......
225 225
		}
226 226
		exit();
227 227
	}
228
	// Validate send email
229
	function mail($fromaddress, $toaddress, $subject, $message) {
230
		$fromaddress = preg_replace('/[\r\n]/', '', $fromaddress);
231
		$toaddress = preg_replace('/[\r\n]/', '', $toaddress);
232
		$subject = preg_replace('/[\r\n]/', '', $subject);
233
		if ($fromaddress=='') {
234
			$fromaddress = SERVER_EMAIL;
235
		}
236
		if(defined('CHARSET')) { 
237
			$charset = DEAFULT_CHARSET; 
238
		} else {
239
			$charset='utf-8';
240
		}
241
		$headers  = "MIME-Version: 1.0\n";
242
		$headers .= "Content-type: text/plain; charset=".$charset."\n";
243
		$headers .= "X-Priority: 3\n";
244
		$headers .= "X-MSMail-Priority: Normal\n";
245
		$headers .= "X-Mailer: Website Baker\n";
246
		$headers .= "From: ".$fromaddress."\n";
247
		$headers .= "Return-Path: ".$fromaddress."\n";
248
		$headers .= "Reply-To: ".$fromaddress."\n";
249
		$headers .= "\n"; // extra empty line needed??
250
		if (OPERATING_SYSTEM=='windows') {
251
			str_replace("\n","\r\n",$headers);
252
			str_replace("\n","\r\n",$message);
253
		}	
254
		if(mail($toaddress, $subject, $message, $headers, "-f $fromaddress")) {
255
			return true;
256
		} else {
257
			return false;
258
		}
259
	}
228 260

  
229 261
}
230 262
?>

Also available in: Unified diff