Web Analytics Made Easy -
StatCounter Mail Attachment - CodingForum

Announcement

Collapse
No announcement yet.

Mail Attachment

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mail Attachment

    I'm looking to send a file on my server called 'Spreadsheet.xls' as an attachment in php mail.

    PHP Code:
    include "../templates/email_body.php";


    $email_headers "From: [email protected]\r\n";
    $email_headers .= "BCC: [email protected]\r\n";
    $email_headers .= "Content-Type: text/html;\r\n charset=\"iso-8859-1\"\r\n";
    mail("$customer_email","Sending Attachment",$email_message,$email_headers); 
    The file Spreadsheet.xls is in the same folder as this php file.

    I've had a look around on google and it seems a lot harder to do than it should!? Most the articles are about uploading a document to be sent by email, but I already have the file to send...?

  • #2
    i just googled php mail sending attachment and found several examples. you might try that, i have never done the attatchment deal myself but the examples are fairly clear.
    I am not crazy, my computer had me checked but its on dialup and im still waiting for results :)
    A good way to remember objects from arrays is you shoot objects with arrows Example: $name->id; then Arrays are $name['id'];
    durangod is short for durango dave

    Comment


    • #3
      Thanks, the examples found explain how to send an attached file that has been uploaded. I just want the code to send a file from my server. The only one I could find that looked close was one about sending a zip file, but there was a lot of extra coding for compression

      Comment


      • #4
        well maybe we both can learn something here.

        have you seen this

        A simple PHP script with the ability to send an email message including a single file attachment using the PHP's native mail() function.


        i was looking at this line, im not sure if thats all you need or not

        PHP Code:

        $header 
        .= "Content-Disposition: attachment;filename=\"".$filename."\"\r\n\r\n"
        I am not crazy, my computer had me checked but its on dialup and im still waiting for results :)
        A good way to remember objects from arrays is you shoot objects with arrows Example: $name->id; then Arrays are $name['id'];
        durangod is short for durango dave

        Comment


        • #5
          Try using phpmailer. It makes life incredibly easy for sending emails, html emails, emails with attachments etc.

          The only problem with it you might run into is on line 1471 where I had to change the php version from 6 to 5 (and then a few lines below) to stop php moaning about deprecated functions (magic quotes).
          "Tango says double quotes with a single ( ' ) quote in the middle"
          '$Name says single quotes with a double ( " ) quote in the middle'
          "Tango says double quotes ( \" ) must escape a double quote"
          '$Name single quotes ( \' ) must escape a single quote'

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎