Attachement Form Mail in php


 
Thread Tools Search this Thread
Top Forums Web Development Attachement Form Mail in php
# 1  
Old 07-30-2011
Attachement Form Mail in php

Dear Sir,

I have used a php form mail code in a website. The problem I am facing is: the text in mail body is getting injected to a configured yahoo mail ID, but no attachement file. I need the attachement to go to the configured yahoo mail ID.

The code I have used :

Code:
<?php
 //--------------------------Set these paramaters--------------------------
 
// Subject of email sent to you.
 $subject = 'Test mail'; 

// Your email address. This is where the form information will be sent. 
$emailadd = 'career@icfa.co.in'; 

// Where to redirect after form is processed. 
$url = 'http://www.icfa.co.in/register.php'; 

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
 $req = '1'; 

// --------------------------Do not edit below this line--------------------------
 $text = "Results from form:\n\n"; 
$space = ' ';
 $line = '
 ';
 foreach ($_POST as $key => $value)
 {
 if ($req == '1')
 {
 if ($value == '')
 {echo "$key is empty";die;}
 }
 $j = strlen($key);
 if ($j >= 20)
 {echo "Name of form element $key cannot be longer than 20 characters";die;}
 $j = 20 - $j;
 for ($i = 1; $i <= $j; $i++)
 {$space .= ' ';}
 $value = str_replace('\n', "$line", $value);
 $conc = "{$key}:$space{$value}$line";
 $text .= $conc;
 $space = ' ';
 }
 mail($emailadd, $subject, $text, $attachement, 'From: '.$emailadd.'');
 echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
 // send the message 

  mail("$to_name <$to_email>", $subject, $message, $headers);  

  print "Mail sent.  Thank you for using ICFa web Mailer."; 


 ?>

is there any one to help me this problem ?

thanks in adv.

roy
bangalore

Last edited by pludi; 07-31-2011 at 10:00 AM..
# 2  
Old 08-01-2011
This guy uses just one mail call and lots more header and processing: PHP mail function for sending single attachments | PHP Forums

I guess if you send 8 bit not base 64 encoded, it can be simpler.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Send file attachement in mail

Hello, I am able to attache the file in UNIX/LINUX script using following code. MAILFORMAT="Please do not replay this mail.This mail is auto generated." echo -e $MAILFORMAT | mailx -r autoreplay@gmail.com -a filename -s "status" xyz@gmail.com But same I am not able attache... (6 Replies)
Discussion started by: nes
6 Replies

2. Programming

Mail form with attachement & thank you - popup window

Dear Sir, I have a mail form ( file name: sendresults ) in php. This php code supports the sending all text of the checkboxes of Register Page of a website. But it does't send attachement ( word, excel, jpg, image, etc. ) Now , I want to add the attachement code and a javascript of "thank... (0 Replies)
Discussion started by: swapan
0 Replies

3. Shell Programming and Scripting

sending attachement in mail

Hi , I am using the below code to send mail through a script which run as a cron job. msgdate=`date +"%a, %e %Y %T %z"` daemail=$(cat <<! From: $from To: $emailtarget Subject: $subject Mime-Version: 1.0 Content-Type: multipart/mixed; Content-Disposition: inline $priority $CONTENT !)... (2 Replies)
Discussion started by: ahamed
2 Replies

4. Shell Programming and Scripting

attachement through mail command

Can't attach text files to 'mail' command. I dont have mutt or mailx to use on my server. so i have to use mail command any help would be great. Regards, Kiran (1 Reply)
Discussion started by: dddkiran
1 Replies

5. UNIX for Advanced & Expert Users

How to read mail attachement

I want to read attachements sent to unix mail id and save the attachement in folder. I may receive the mails from different mail clients(outlook, lotus ..etc). Attachements are in CSV(comma saperate) format. Let me know the shell script code for this. Regards, Venkat (1 Reply)
Discussion started by: svenkatareddy
1 Replies

6. Shell Programming and Scripting

query about Attachement in mail

Hi All, I have general query that ...in my script i used uuencode option like below. cd /location (cat test.txt uuencode test.csv test.csv ) | mail -s "test mail" "mail_id" but whenever i run the above command its giving error like below ./testscript.sh: uuencode not found: ... (1 Reply)
Discussion started by: Shahul
1 Replies

7. Shell Programming and Scripting

How to send Mail with Attachement

Hi Can somebody help me in wirting shell script in the following way.Desperately i have poseted this.. 1.How can I connect to Oracle(Sqlplus) from UNIX. 2.After connecting to it I have to execute an oracle proceudure.. 3.Execution of the procedure will give some set of rows.. 4.The set of... (6 Replies)
Discussion started by: chgopi
6 Replies

8. UNIX for Dummies Questions & Answers

Send a mail with an attachement of a file

I wanted to try sending a mail with an attachement at command prompt in unix. Some one please advise that how we can do it ? Thanks, :) (2 Replies)
Discussion started by: gaddeg
2 Replies

9. UNIX for Dummies Questions & Answers

Send a mail with a subject and an attachement

Dear All: I want to send a message to a list of people with a subject and an attachement, currently I am using the following command into a shell script: uuencode $FILENAME.gz $FILENAME.gz | mail john.kennedy@mycompany.com m.m@mycompany.com With this command I can send the message for a... (1 Reply)
Discussion started by: josecollantes
1 Replies
Login or Register to Ask a Question