469,927 Members | 1,735 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Attachments Problems

Good Day

I have published a website and everything works expect for my forms. I can't seem to send the attachments to the email address according to the uploader. I don't know what i am doing wrong please help ....................i really need serious help
the field picture2, picture4 and video are uploaders
$firstname = $_POST['FirstName'];
$lastname = $_POST['LastName'];
$email = $_POST['EmailAddress'];
$number = $_POST['ContactNumber'];
$NameOfAdvertisedItem = $_POST['NameOfAdvertisedItem'];
$Genres = $_POST['Genres'];
$Format = $_POST['Format'];

function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($file);
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use diff. tyoes here
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";
if (mail($mailto, $subject, "", $header)) {
echo = "mail send ... OK"; // or use booleans here
} else {
echo = "mail send ... ERROR!";
// how to use
$my_file = "somefile.zip";
$my_path = $_SERVER['DOCUMENT_ROOT']."/Main/Sign_up/upload/";
$my_name = "Olaf Lederer";
$my_mail = "mainsignup@contiads.co.za";
$my_replyto = "info@contiads.co.za";
$my_subject = "This is a mail with attachment for ads.";
$my_message = "Hallo,\r\ndo you like this script? I hope it will help.\r\n\r\ngr. Olaf";
mail_attachment($my_file, $my_path, "mainsignup@contiads.co.za", $my_mail, $my_name, $my_replyto, $my_subject, $my_message);
$Picture2 = $_POST['Picture2'];
$Picture4 = $_POST['Picture4'];
$video = $_POST['video'];
$ShortDescription = $_POST['ShortDescription'];
$country = $_POST['country'];
$Province = $_POST['Province'];
$CityTown = $_POST['CityTown'];
$Duration = $_POST['Duration'];
$tnc_agree = $_POST['tnc_agree'];
$to = "ContiAds! <mainsignup@contiads.co.za>";
$subject = "RE: New ContiAds SignUp!";
$body = "<html>".
"<title>Contact Request</title>".
"<style type='text/css'>".
"body,td,th {".
"font-family: Geneva, Arial, Helvetica, sans-serif;".
"font-size: 12px;".
".style1 {font-size: 24px}".
"<p align='center' class='style1'>ContiAds New Signup</p>".
"<table width='498' border='0' align='center' cellpadding='5' cellspacing='0'>".
"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
"<td width='104' valign='top'>Full Name:</td>".
"<td width='374'>".$firstname." ".$lastname."</td>".
"<td valign='top'>Contact Number:</td>".
"<td valign='top'>E-mail Address:</td>".
"<td valign='top'>Number of Advertised Items:</td>".
"<td valign='top'>Genres:</td>".
"<td valign='top'>Format:</td>".
"<td valign='top'>Short Description:</td>".
"<td valign='top'>Country:</td>".
"<td valign='top'>Province:</td>".
"<td valign='top'>City / Town:</td>".
"<td valign='top'>Duration:</td>".
"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
//Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . $email . "\r\n";
//$headers .= 'Cc: myboss@example.com' . "\r\n";
if (mail($to, $subject, $body, $headers)) {
<script language="javascript" type="text/javascript">
} else {
<script language="javascript" type="text/javascript">

Please do not use uppercase cries for help and enclose your code within the appropriate code tags! See the Posting Guidelines on this. - moderator
Mar 4 '08 #1
3 1374
664 Expert 512MB
I looked at this somewhat quickly.
First I would start with just the First and Last name, See if you can make that work then continue to build it. Make it simple...
and you might have to many $header info. in your php code.
and who are you $mailto ???

Mar 4 '08 #2
Thank you for replying

I'm mailling it to the websites email address..Which i created using hosts pop3 email feature.

Thing is the other fields i do receive them when the form is submitted. Its the attachments that don't appear in the mail ! :-( and i really need them.

If possible could you please restructure the scripts in a way you think that will work best ! please
Mar 4 '08 #3
Please Help Me I'm Running Out Of Time
Mar 5 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by S_p_ike | last post: by
1 post views Thread by JulioHM | last post: by
2 posts views Thread by Osiris Sawiris | last post: by
1 post views Thread by Trond A. S. Andersen | last post: by
4 posts views Thread by Peter Wullems | last post: by
1 post views Thread by Peter Wullems | last post: by
1 post views Thread by Steve Holden | last post: by
130 posts views Thread by Gianni Mariani | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.