473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Attachments Problems

4
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
[php]<?php
$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);
fclose($handle);
$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>".
"<head>".
"<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}".
"</style></head>".
"<body>".
"<p align='center' class='style1'>ContiAds New Signup</p>".
"<table width='498' border='0' align='center' cellpadding='5' cellspacing='0'>".
"<tr>".
"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
"</tr>".
"<tr>".
"<td width='104' valign='top'>Full Name:</td>".
"<td width='374'>".$firstname." ".$lastname."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Contact Number:</td>".
"<td>".$number."</td>".
"</tr>".
"<tr>".
"<td valign='top'>E-mail Address:</td>".
"<td>".$email."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Number of Advertised Items:</td>".
"<td>".$NameOfAdvertisedItem."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Genres:</td>".
"<td>".$Genres."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Format:</td>".
"<td>".$Format."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Short Description:</td>".
"<td>".$ShortDescription."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Country:</td>".
"<td>".$country."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Province:</td>".
"<td>".$Province."</td>".
"</tr>".
"<tr>".
"<td valign='top'>City / Town:</td>".
"<td>".$CityTown."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Duration:</td>".
"<td>".$Duration."</td>".
"</tr>".
"<tr>".
"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
"</tr>".
"</table>".
"</body>".
"</html>";
//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">
location.replace("Sign%20Up%20Success.htm");
</script>
<?php
} else {
?>
<script language="javascript" type="text/javascript">
location.replace("Sign%20Up%20Failure.htm");
</script>
<?php
}?>[/php]

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 1590
nomad
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 ???

nomad
Mar 4 '08 #2
Veli
4
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
Veli
4
Please Help Me I'm Running Out Of Time
Mar 5 '08 #4

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

Similar topics

2
by: S_p_ike | last post by:
Hi all, I have a problem with mail with attachments. To send e-mail with attachments from a form, I use Setec Astronomy's libmail class (v 1.4) (available here http://www.phpclasses.org/) ...
15
by: tabonni | last post by:
Hi I try to grab the checked files from HTML page and then send those PDF files as attachments. It can just send email, there are no PDF files attached. Can anybody point out my error? My...
1
by: JulioHM | last post by:
Hi all, My question is quite simple. It´s about JavaMail API 1.3 and how it handles file attachments. I've been googling around, but without luck. Well, question is: How exactly does it handle...
2
by: Osiris Sawiris | last post by:
I inherited an Inventory control application that updates the stock from the branches at the end of each day. We receive the stock transactions via e-mail attachments (Excel Sheets). Those...
1
by: Trond A. S. Andersen | last post by:
Hi all, I'm working on a project in which i need to send mail attachments in the form of Excel documents from a .NET C# application. I've written a class which creates the Excel document using...
4
by: Peter Wullems | last post by:
I am trying to convert some code from VB to C# where VB.NET allows the following: MailItem.Attachments.Add(filename) In the same situation C# appears to look for the following:...
1
by: Peter Wullems | last post by:
I use C# to parse incoming emails for a predefined type and structure of message content and construct replies automatically, attach a file and place the generated emails in the drafts folder. ...
4
by: Liz Patton | last post by:
Here's the exception: System.Exception: Unable to send mail: Could not access 'CDO.Message' object. ---> System.Web.HttpException: Could not access 'CDO.Message' object. --->...
1
by: Steve Holden | last post by:
I'm having some trouble getting attachments right for all recipients, and it seems like Apple's mail.app is the pickiest client at the moment. It doesn't handle attachments that both Thunderbird...
130
by: Gianni Mariani | last post by:
Attached example CPP files makes it easier to post code and extract code from posts. It's unimaginable at this time where virtually any news reader is capable of dealing with attachments to stick...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.