Jump to content

Secure, accessible, customisable php mailer script?


Gilmore

Recommended Posts

Is there such thing as a secure, accessible, customisable php mailer script?

My PHP isn't so hot at the mo and need a script that does all of the above.

I've played with the following so far :

[url=http://green-beast.com/blog/?page_id=71]http://green-beast.com/blog/?page_id=71[/url] - Looks a bit OTT for my purposes and seems to be a bitch to customise.
[url=http://www.dagondesign.com/articles/secure-php-form-mailer-script/]http://www.dagondesign.com/articles/secure-php-form-mailer-script/[/url] - And this one was a bit too complicated for me.

Any ideas?

Thanks!

heres one i made...

[code]
<?
function get_filetype($filepath,$extension=4){
return substr($filepath, -$extension);
}

function email($to, $subject, $text, $from="", $file=""){
if(is_array($to)) $to = implode(", ",$to);
if(empty($to)) return FALSE;
if(empty($subject)) $subject="N/A";
$subject=strip_tags($subject);
$text = wordwrap($text, 77, "<br />\n");
if(file_exists($file)){
  switch(get_filetype($file,3)){
  case ".rm": $type="audio/x-realaudio"; break;
  case ".qt": $type="video/quicktime"; break;
  }
  switch(get_filetype($file)){
  case ".avi": $type="video/avi"; break;
  case ".doc": $type="application/msword"; break;
  case ".gif": $type="image/gif"; break;
  case ".jpg": $type="image/jpeg"; break;
  case ".mov": $type="video/mov"; break;
  case ".mpg": $type="video/mpeg"; break;
  case ".pdf": $type="application/pdf"; break;
  case ".png": $type="image/png"; break;
  case ".ram": $type="audio/x-pn-realaudio"; break;
  case ".tar": $type="application/x-tar"; break;
  case ".wav": $type="audio/wav"; break;
  case ".zip": $type="application/x-zip-compressed"; break;
  }
  switch(get_filetype($file,5)){
  case ".html": $type="text/html"; break;
  case ".mpeg": $type="video/mpeg"; break;
  }
  if(!isset($type)) $type="text/plain";
  $content = fread(fopen($file,"r"),filesize($file));
  $content = chunk_split(base64_encode($content));
  $name = basename($file);
}
$uid = strtoupper(md5(uniqid(time())));
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/html\n";
$header .= "--$uid\n";
if(file_exists($file)){
  $header .= "Content-Type: $type; name=\"$name\"\n";
  $header .= "Content-Transfer-Encoding: base64\n";
  $header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
  $header .= "$content\n";
  $header .= "--$uid--";
}
if(mail($to, $subject, $text, $header)) return TRUE;
else return FALSE;
}
?>
[/code]

i think tha's sorta what your lookin for :-)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.