Jump to content

Adding attachments to email script


BenMo

Recommended Posts

Hello.  I've seen that questions similar to this are on other areas of the board, however do to my embarrassing non-familiarity with php, they aren't much help because my skills are limited to copy and paste.  If someone could help with this simple modification I would be incredibly greatful!

I've created (through putting together other tutorials) a php script and accompanying HTML code that successfully emails information filled out in form to a specified email address.  The page can be found <A HREF = "http://jellywars.com/brbtest/info.html">here</A>, where you can look at the source.  The php code is pasted below...

[code]
<?
// ------------- CONFIGURABLE SECTION ------------------------
$mailto = '[email protected]' ;
$subject = "CustomGameOrder" ;
$formurl = "http://www.jellywars.com/brbtest/info.html" ;
$errorurl = "http://http://www.jellywars.com/brb/error.html" ;
$thankyouurl = "http://www.jellywars.com/brbtest/info.html" ;
$uself = 0;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$email2 = $_POST['email2'] ;
$lastname = $_POST['lastname'] ;
$gender = $_POST['gender'] ;
$mom = $_POST['mom'] ;
$dad = $_POST['dad'] ;
$hobby = $_POST['hobby'] ;
$neighborhood = $_POST['neighborhood'] ;
$message1 = $_POST['message1'] ;
$message2 = $_POST['message2'] ;
$message3 = $_POST['message3'] ;
$finalmessage = $_POST['finalmessage'] ;
$comments = $_POST['comments'] ;

$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
  header( "Location: $formurl" );
  exit ;
}
if (empty($name) || empty($email)) {
  header( "Location: $errorurl" );
  exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
  header( "Location: $errorurl" );
  exit ;
}
if (get_magic_quotes_gpc()) {
  $comments = stripslashes( $comments );
}
$messageproper =
  "This message was sent from:\n" .
  "$http_referrer\n" .
  "------------------------------------------------------------\n" .
  "FirstName: $name\n" .
  "LastName: $lastname\n" .
  "Gender: $gender\n" .
  "Mom: $mom\n" .
  "Dad: $dad\n" .
  "Hobby: $hobby\n" .
  "Neighborhood: $neighborhood\n" .
  "Message1: $message1\n" .
  "Message2: $message2\n" .
  "Message3: $message3\n" .
  "FinalMessage: $finalmessage\n" .
  "Email of sender: $email\n" .
  "Confirm Email: $email2\n" .
  "------------------------- COMMENTS -------------------------\n\n" .
  $comments .
  "\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper,
  "From: \"$lastname\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );
header( "Location: $thankyouurl" );
exit ;
?>
[/code]

I need to add on to this script so that it handles sending images files also (preferably 3 separate images).  I know that this is no small task, but I'm sure it's been done before.  If someone could point me in the direction of some code that I can combine with this code, then that would be fantastic.  Thank you so much for your time!
Link to comment
https://forums.phpfreaks.com/topic/32305-adding-attachments-to-email-script/
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.