Location: PHPKode > projects > MyMail Webmail > global.php
<?php

#MyMail 3.0 Configuration


/* Let's Setup Webmail Footer */
$mail_footer = '\r\n____________________________\r\nMessage Sent Using MyMail.\r\n';

/* Message Type */
$type = array("text", "multipart", "message", "application", "audio", "image", "video", "other");

/* Encoding */
$encoding = array("7bit", "8bit", "binary", "base64", "quoted-printable", "other");

/* Validate Address */
function validate_email($val)
{
	if($val != "")
	{
		$pattern = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/";
		if(preg_match($pattern, $val))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}


/* Parse Message Body */
function parse($structure)
{
	global $type;
	global $encoding;
	
	// create an array to hold message sections
	$ret = array();
	
	// split structure into parts
	$parts = $structure->parts;
	
	#Move through message parts.
	for($x=0; $x<sizeof($parts); $x++)
	{
		$ret[$x]["pid"] = ($x+1);	
	
		$this = $parts[$x];
	
		/* Default To Text */
		if ($this->type == "") { $this->type = 0; }
		$ret[$x]["type"] = $type[$this->type] . "/" . strtolower($this->subtype);	
	
		/* Default to 7-Bit */
		if ($this->encoding == "") { $this->encoding = 0; }
		$ret[$x]["encoding"] = $encoding[$this->encoding];	
		
		$ret[$x]["size"] = strtolower($this->bytes);	
		
		$ret[$x]["disposition"] = strtolower($this->disposition);	
		
		if (strtolower($this->disposition) == "attachment")
		{
			$zparam = $this->parameters;
			foreach ($zparam as $z)
			{
				if($z->attribute == "FILENAME")
				{
				$ret[$x]["name"] = $z->value;	
				break;			
				}
			}
		}
}

return $ret;
}
/* iterate through object returned by parse() */
/* Create New Array For Attachments */

function get_attachments($arr)
{
	for($x=0; $x<sizeof($arr); $x++)
	{
		if($arr[$x]["disposition"] == "attachment")
		{
		$ret[] = $arr[$x];
		}
	}
	return $ret;
}

/* Remove Uneeded Stuff From E-Mail Addresses */
/* Return Stripped E-Mail Address */
function clean_address(&$val, $index)
{
	// clean out whitespace
	$val = trim($val);
	// look for angle braces
	$begin = strrpos($val, "<");
	$end = strrpos($val, ">");
	if ($begin !== false) 
	{
		// return whatever is between the angle braces
		$val = substr($val, ($begin+1), $end-$begin-1);
	}
}
?>
Return current item: MyMail Webmail