Jump to content

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 = "admin@webdesigndigital.com";
$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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.