Jump to content

Help me with my Mail script Please


BigChili

Recommended Posts

I created this script that mails me the selections from a webpage's form. There is a place for an attachment. If the user does not add an attachment, the email still comes to me - but it's totally blank. NOTHING!!!! - If they attach a file, no problem, everything comes through just fine including the attachment.

My code is below. To see the form, you can see it at [a href=\"http://www.clownco.com/emb_quote.html\" target=\"_blank\"]www.clownco.com/emb_quote.html[/a].

Any help you can give would be greatly appreciated.


Thanks, in advance

Bryan

[code]

<?php
// Read POST request params into global vars





$from="";//put here the address the e-mail is coming from
$errorurl = "http://www.clownco.com/error.html";
$thankyouurl = "http://www.clownco.com/thanks.html";
$to = "art@clownco.com";
$subject = "ONLINE EMBROIDERY QUOTE";
$qty = $_REQUEST['qty'];
$garment = $_REQUEST['garment'];
$garment_color = $_REQUEST['garment_color'];
$art = $_REQUEST['art'];
$fileatt      = $_POST['fileatt'];
$location_1 = $_REQUEST['location_1'];
$location_2 = $_REQUEST['location_2'];
$location_3 = $_REQUEST['location_3'];
$company = $_REQUEST['company'];
$name = $_REQUEST ['name'];
$city = $_REQUEST['city'];
$state = $_REQUEST['state'];
$zip = $_REQUEST['zip'];
$phone = $_REQUEST['phone'];
$email = $_REQUEST['email'];
$comments = $_REQUEST['comments'];
$address = $_REQUEST ['address'];





// Obtain file upload vars
$fileatt      = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];

$headers = "From: $email";

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
            "Content-Type: multipart/mixed;\n" .
            " boundary=\"{$mime_boundary}\"";

// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
           "--{$mime_boundary}\n" .
           "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
           "Content-Transfer-Encoding: 7bit\n\n" .
   "------------GARMENT INFORMATION------------ \n\n" .
   "Quantity:--- $qty \n" .
  "Garment Type:--- $garment \n" .
  "Garment Color:--- $garment_color \n\n" .
  "------------EMBROIDERY INFORMATION------------ \n\n" .
  "ART:--- $art \n" .
  "Embroidery Location 1:--- $location_1 \n" .
  "Embroidery Location 2:--- $location_2 \n" .
  "Embroidery Location 3:--- $location_3 \n\n" .
  "------------CUSTOMER INFORMATION------------ \n\n" .
  "Company:--- $company \n" .
  "Name:--- $name \n" .
  "Address: \n" .
  "$address \n" .
  "$city, $state $zip \n" .
  "Phone number:--- $phone \n" .
  "Email Address:--- $email \n\n" .
  "------------OTHER COMMENTS------------ \n\n" .
  "Comments: \n" .
  "$comments " . "\n\n";


// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
            "Content-Type: {$fileatt_type};\n" .
            " name=\"{$fileatt_name}\"\n" .
            //"Content-Disposition: attachment;\n" .
            //" filename=\"{$fileatt_name}\"\n" .
            "Content-Transfer-Encoding: base64\n\n" .
            $data . "\n\n" .
            "--{$mime_boundary}--\n";

}





// Send the message
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
header("Location: thanks.html");
} else {
header("Location: error.html");
}

?>
[/code]

Link to comment
Share on other sites

Hi there i read your post, and i understood what i could, You sate that when a user sends a email message with out a attachment the message dosent have no relavent information within the mail message. but if the user does attach a file you get all the inforation needed i think this is correct ok.

The users that use the mail script will have to be the ones that are a members to your website or all the requast information in your code not work.

Try to logon as a user then just press submit you should receve all the requst information becouse your loged in as a user tyr that first then post your findings.

Make sure that users sendind messages are the users that are logged as a member to your website ok.

good luck.
Link to comment
Share on other sites

[!--quoteo(post=349989:date=Feb 27 2006, 04:39 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Feb 27 2006, 04:39 PM) [snapback]349989[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi there i read your post, and i understood what i could, You sate that when a user sends a email message with out a attachment the message dosent have no relavent information within the mail message. but if the user does attach a file you get all the inforation needed i think this is correct ok.

The users that use the mail script will have to be the ones that are a members to your website or all the requast information in your code not work.

Try to logon as a user then just press submit you should receve all the requst information becouse your loged in as a user tyr that first then post your findings.

Make sure that users sendind messages are the users that are logged as a member to your website ok.

good luck.
[/quote]

I think you misunderstood my post somewhat. The problem that I'm having i think you understand. But I'm not sure you understand that there are no users as in "Logged In" users filling the form. This form is for anyone on the internet to fill out. Then the PHP code takes the contents of my form and emails it to ME. Should be very simple.

But I'm so new to PHP.


Anyone know what's going on????
Link to comment
Share on other sites

[!--quoteo(post=350331:date=Feb 28 2006, 01:22 PM:name=BigChili)--][div class=\'quotetop\']QUOTE(BigChili @ Feb 28 2006, 01:22 PM) [snapback]350331[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Can anyone help me? I'm not a PHP programmer, I'm a graphic artist just trying to make this thing work???

Thanks,

Bryan
[/quote]

2 options..

1. hire a programmer ;)
2. create an if statement something like

if (didTheyIncludeAttachment == 'true'){
SendEmailWithAttachmentFunction();
}else{
SendEmailWithoutAttachmentFunction();
}

Now, the second option is not the best ever so dont take it to heart. Just trying to help.
Link to comment
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.