version 1.17, 2002/07/30 15:07:41
|
version 1.21, 2002/09/30 03:10:48
|
Line 1
|
Line 1
|
<? |
<?php |
/* |
/* |
* email_message.php |
* email_message.php |
* |
* |
Line 22 class email_message_class
|
Line 22 class email_message_class
|
/* Public variables */ |
/* Public variables */ |
|
|
var $email_regular_expression="^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}\$"; |
var $email_regular_expression="^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}\$"; |
var $mailer="http://www.phpclasses.org/mimemessage"; |
var $mailer='http://www.phpclasses.org/mimemessage $Revision$'; |
var $default_charset="ISO-8859-1"; |
var $default_charset="ISO-8859-1"; |
var $line_break="\n"; |
var $line_break="\n"; |
var $file_buffer_length=8000; |
var $file_buffer_length=8000; |
Line 96 class email_message_class
|
Line 96 class email_message_class
|
{ |
{ |
if(!defined("PHP_OS")) |
if(!defined("PHP_OS")) |
return($this->OutputError("it is not possible to set the Return-Path header with your PHP version")); |
return($this->OutputError("it is not possible to set the Return-Path header with your PHP version")); |
if(!strcmp(PHP_OS,"WIN")) |
if(!strcmp(substr(PHP_OS,0,3),"WIN")) |
return($this->OutputError("it is not possible to set the Return-Path header directly from a PHP script on Windows")); |
return($this->OutputError("it is not possible to set the Return-Path header directly from a PHP script on Windows")); |
if($this->GetPHPVersion()<4000005) |
if($this->GetPHPVersion()<4000005) |
return($this->OutputError("it is not possible to set the Return-Path header in PHP version older than 4.0.5")); |
return($this->OutputError("it is not possible to set the Return-Path header in PHP version older than 4.0.5")); |
} |
} |
} |
} |
$success=(strlen($return_path) ? mail($to,$subject,$body,$headers," -f".$return_path) : mail($to,$subject,$body,$headers)); |
$success=(strlen($return_path) ? mail($to,$subject,$body,$headers,"-f".$return_path) : mail($to,$subject,$body,$headers)); |
return($success ? "" : $this->OutputError("it was not possible to send e-mail message")); |
return($success ? "" : $this->OutputError("it was not possible to send e-mail message")); |
} |
} |
|
|
Line 146 class email_message_class
|
Line 146 class email_message_class
|
if(!IsSet($this->delivery["Headers"]) |
if(!IsSet($this->delivery["Headers"]) |
|| count($this->delivery["Headers"])==0) |
|| count($this->delivery["Headers"])==0) |
return($this->OutputError("message has no headers")); |
return($this->OutputError("message has no headers")); |
$line_break=((defined("PHP_OS") && !strcmp(PHP_OS,"WIN")) ? "\r\n" : $this->line_break); |
$line_break=((defined("PHP_OS") && !strcmp(substr(PHP_OS,0,3),"WIN")) ? "\r\n" : $this->line_break); |
$headers=$this->delivery["Headers"]; |
$headers=$this->delivery["Headers"]; |
for($headers_text=$to=$subject="",$header=0,Reset($headers);$header<count($headers);Next($headers),$header++) |
for($headers_text=$to=$subject="",$header=0,Reset($headers);$header<count($headers);Next($headers),$header++) |
{ |
{ |
Line 210 class email_message_class
|
Line 210 class email_message_class
|
case "parallel": |
case "parallel": |
$this->GetPartBoundary($part); |
$this->GetPartBoundary($part); |
$headers["Content-Type"]=$full_type."; boundary=\"".$this->parts[$part]["BOUNDARY"]."\""; |
$headers["Content-Type"]=$full_type."; boundary=\"".$this->parts[$part]["BOUNDARY"]."\""; |
break 2; |
break; |
|
default: |
|
return($this->OutputError("multipart Content-Type sub_type $sub_type not yet supported")); |
} |
} |
|
break; |
default: |
default: |
return($this->OutputError("Content-Type: $full_type not yet supported")); |
return($this->OutputError("Content-Type: $full_type not yet supported")); |
} |
} |
Line 236 class email_message_class
|
Line 239 class email_message_class
|
case "application": |
case "application": |
if(IsSet($this->parts[$part]["FILENAME"])) |
if(IsSet($this->parts[$part]["FILENAME"])) |
{ |
{ |
if(!($file=@fopen($this->parts[$part]["FILENAME"],"r"))) |
if(!($file=@fopen($this->parts[$part]["FILENAME"],"rb"))) |
return($this->OutputError("could not open part file")); |
return($this->OutputError("could not open part file")); |
while(!feof($file)) |
while(!feof($file)) |
{ |
{ |
Line 296 class email_message_class
|
Line 299 class email_message_class
|
$body.=$part_body; |
$body.=$part_body; |
} |
} |
$body.=$boundary."--".$this->line_break; |
$body.=$boundary."--".$this->line_break; |
break 2; |
break; |
|
default: |
|
return($this->OutputError("multipart Content-Type sub_type $sub_type not yet supported")); |
} |
} |
|
break; |
default: |
default: |
return($this->OutputError("Content-Type: $full_type not yet supported")); |
return($this->OutputError("Content-Type: $full_type not yet supported")); |
} |
} |
Line 881 class email_message_class
|
Line 887 class email_message_class
|
return($error); |
return($error); |
} |
} |
|
|
|
Function Mail($to,$subject,$message,$additional_headers="",$additional_parameters="") |
|
{ |
|
$this->headers=array("To"=>$to,"Subject"=>$subject); |
|
$this->body=-1; |
|
$this->body_parts=0; |
|
$this->parts=array(); |
|
$this->delivery=array("State"=>""); |
|
$this->error=""; |
|
$content_type=""; |
|
while(strlen($additional_headers)) |
|
{ |
|
ereg("([^\r\n]+)(\r?\n)?(.*)\$",$additional_headers,$matches); |
|
$header=$matches[1]; |
|
$additional_headers=$matches[3]; |
|
if(!ereg("^([^:]+):[ \t]+(.+)\$",$header,$matches)) |
|
{ |
|
$this->error="invalid header \"$header\""; |
|
return(0); |
|
} |
|
if(strtolower($matches[1])=="content-type") |
|
{ |
|
if(strlen($content_type)) |
|
{ |
|
$this->error="the content-type header was specified more than once."; |
|
return(0); |
|
} |
|
$content_type=$matches[2]; |
|
} |
|
else |
|
$this->SetHeader($matches[1],$matches[2]); |
|
} |
|
if(strlen($additional_parameters)) |
|
{ |
|
if(ereg("^[ \t]*-f[ \t]*([^@]+@[^ \t]+)[ \t]*(.*)\$"/*"^[ \t]?-f([^@]@[^ \t]+)[ \t]?(.*)\$"*/,$additional_parameters,$matches)) |
|
{ |
|
if(!eregi($this->email_regular_expression,$matches[1])) |
|
{ |
|
$this->error="it was specified an invalid e-mail address for the additional parameter -f"; |
|
return(0); |
|
} |
|
if(strlen($matches[2])) |
|
{ |
|
$this->error="it were specified some additional parameters after -f e-mail address parameter that are not supported"; |
|
return(0); |
|
} |
|
$this->SetHeader("Return-Path",$matches[1]); |
|
} |
|
else |
|
{ |
|
$this->error="the additional parameters that were specified are not supported"; |
|
return(0); |
|
} |
|
} |
|
if(strlen($content_type)==0) |
|
$content_type="text/plain"; |
|
$definition=array( |
|
"Content-Type"=>$content_type, |
|
"DATA"=>$message |
|
); |
|
$this->CreateAndAddPart($definition); |
|
$this->Send(); |
|
return(strlen($this->error)==0); |
|
} |
|
|
}; |
}; |
|
|
?> |
?> |
|
|