I have a webform on my site with many data fields, including a file upload field.
I have another page on my site which requires a much simpler form, so I used the longer form, and have scaled it back to just the user name and user email.
I have tested the new (simple) form, and it works great.
However, the file attachment language is still in the form handler, and still sends an empty attachment.
I need some help stripping out all the file attachment parts.
I have tried to strip the parts myself, but with each attempt, the form fails to send.
I have included the working version of the form handler with the file attachment language still included.
Form Handler:
<?php
$name = $_POST['userName'];
$email = $_POST['userEmail'];
$composition =
"rnName: " . $name .
"rnEmail Address: " . $email;
$subject ="Email Subject here";
$fromname ="$name";
$fromemail = "$email";
$mailto = '[email protected]';
//The Content Action
$content = file_get_contents($tmpName);
$content = chunk_split(base64_encode($content));
// A random hash will be necessary to send mixed content
$separator = md5(uniqid(time()));
// Carriage return type (RFC)
$eol = "rn";
// Main header (multipart mandatory)
$headers = "From: ".$fromname." <".$fromemail.">" . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed;". $eol. " boundary="" . $separator . """ .
$eol;
// $headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol . $eol;
// Composition action
$body = "--" . $separator . $eol;
$body .= "Content-Type: text/plain; charset="iso-8859-1"" . $eol;
$body .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
$body .= $composition . $eol;
// The attachment action
$body .= "--" . $separator . $eol;
$body .= "Content-Type: application/octet-stream;". $eol. " name="" . $fileName . """ .
$eol;
$body .= "Content-Transfer-Encoding: base64" . $eol;
$body .= "Content-Disposition: attachment;". $eol . " filename="" . $fileName.""" . $eol .
$eol ;
$body .= $content . $eol;
$body .= "--" . $separator . "--";
mail($mailto, $subject, $body, $headers);
header('location: /somefolder/somepage');
?>