Jump to content

Mail() Function


son

Recommended Posts

Using the mail() function I wondered if there was a way to have all the data stored in csv or Excel spreadsheet to be emailed to given email address? If yes, what would be the term to look for? I have never done such a thing...Many thanks,Son

Link to comment
Share on other sites

Actually: no (whispered). Always send the info in email as it was not too much info, only now is quite long and has also to be uploaded into a program, which accepts spreadsheets... Guess I will learn something new tomorrow then:-)Many thanks,Son

Link to comment
Share on other sites

You've never attached a file to an email before?http://lmgtfy.com/?q=php+mail+attachment
Now reading through many, many websites on the subject I am a bit confused and there might have been a misunderstanding. To attach a file to an email is not a problem, but this is not what I want. I want to take the input from the form and create with this a file, which should be attached to the email. I managed to attach an XML file with$headers .= 'Content-type: text/xml; charset=iso-8859-1' . "\r\n";Trying the content type for an Excel spreadsheet as$headers .= 'Content-type: application/vnd.ms-excel; charset=iso-8859-1' . "\r\n";does list all contents in one column beneath each other. I would need each field value in one column. Where am I going wrong? Also, when the file arrives it gives me a security warning to start off...SonReason for edit: Included the header info I used...
Link to comment
Share on other sites

Now reading through many, many websites on the subject I am a bit confused and there might have been a misunderstanding. To attach a file to an email is not a problem, but this is not what I want. I want to take the input from the form and create with this a file, which should be attached to the email. I managed to attach an XML file with$headers .= 'Content-type: text/xml; charset=iso-8859-1' . "\r\n";Trying the content type for an Excel spreadsheet as$headers .= 'Content-type: application/vnd.ms-excel; charset=iso-8859-1' . "\r\n";does list all contents in one column beneath each other. I would need each field value in one column. Where am I going wrong? Also, when the file arrives it gives me a security warning to start off...SonReason for edit: Included the header info I used...
Finally managed to get it work in pricinple. Works with following header info: if (empty($errors)) { $S = ''; foreach($_POST as $key=>$value){ $S.= $value.","; } $headers .= "X-Mailer: Drupal\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: application/octet-stream; charset=iso-8859-1' . "\r\n"; $headers .= 'Content-Disposition: attachment; filename=test.csv' . "\r\n";Now I only have to figure out how to not send $_POST data for submit button and then I am almost there:-)Son
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...