Jump to content

sending email attachments


forsakenmemory

Recommended Posts

simple question on sending email attachments via a contact form on a website. although because it's for clients i need one of those "browse..." buttons that allows you to search for the file on your computer and then uploads it to the server before sending... if that makes sence.

 

i've looked and tried a couple of net tutorials but they seem pretty usless, maybe i'm going about it wrong can any one help please! thanks...

 

here's the code i already have to attach it to....

 

<?php

$EmailFrom = Trim(stripslashes($_REQUEST['EmailFrom'])); 
$EmailTo = "[email protected]";
$Subject = Trim(stripslashes($_REQUEST['Subject'])); 
$Name = Trim(stripslashes($_REQUEST['Name'])); 
$Tel = Trim(stripslashes($_REQUEST['Tel'])); 
$Website = Trim(stripslashes($_REQUEST['Website'])); 
$Enquiry = Trim(stripslashes($_REQUEST['Enquiry'])); 

function checkEmail($EmailFrom) 
{
   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $EmailFrom)) 
   {
      return FALSE;
   }

   list($Username, $Domain) = split("@",$EmailFrom);

   if(getmxrr($Domain, $MXHost)) 
   {
      return TRUE;
   }
   else 
   {
      if(fsockopen($Domain, 25, $errno, $errstr, 30)) 
      {
         return TRUE; 
      }
      else 
      {
         return FALSE; 
      }
   }
}


if (Trim($EmailFrom)=="") {
print "You did not enter an email address! Please try again";
exit;
}
if(checkEmail($EmailFrom) == FALSE) {
print "The email address you entered was not valid. please try again";
exit;
}
if (Trim($Name)=="") {
print "You did not enter a Name. Please try again.";
exit;
} 
if (Trim($Enquiry)=="") {
print "You did not enter an enquiry. Please go back and try again.";
  exit;
}


$Body = "";
$Body .= "Name: " . $Name . "\n" . "\n";
$Body .= "Tel: " . $Tel . "\n" . "\n";
$Body .= "Website: " . $Website . "\n" . "\n";
$Body .= "Enquiry: " . $Enquiry . "\n";

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");


if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
  print "The was an error! Please go back and try again.";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/72926-sending-email-attachments/
Share on other sites

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.