Sending mail with an attachment

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • p2

    Sending mail with an attachment

    Hi,

    I know how to send a file as an attachment when the file is in my file
    system.

    Now I want to send data as attachment without saving it to the
    filesystem first.

    Under UNIX shell what I do is uuencode and dump the output at the end
    of the 'data' part of the message.

    How can I convert the string to an attachment without the mediation of
    the filesystem?

    (The goal is to allow users to request data by email)

    Thank you all,

  • Alvaro G Vicario

    #2
    Re: Sending mail with an attachment

    *** p2 wrote/escribió (8 Aug 2005 01:00:04 -0700):[color=blue]
    > Now I want to send data as attachment without saving it to the
    > filesystem first.
    >
    > Under UNIX shell what I do is uuencode and dump the output at the end
    > of the 'data' part of the message.
    >
    > How can I convert the string to an attachment without the mediation of
    > the filesystem?[/color]

    So, your data is not in a file and apparently it's not in a string (or you
    wouldn't be asking). Where is it then?


    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • joppeaarts@gmail.com

      #3
      Re: Sending mail with an attachment

      Hello,

      I know that if you send an attachment the file will transformed to
      binary data and encoded in some sort of way. If the email has the
      neccesary headers (MIME-Version: 1.0\r\nContent-type: multipart/mixed;
      boundary=931249 5342k5hk45h8\r\ n) and is split in to two parts (one
      text, one attachment) by the boundary.
      Then give the attachment part the right headers (Content type=<type of
      file>; name=<filename> \r\nContent-transfer-encoding:
      base64\r\nConte nt-disposition: attachment; filename=<filen ame>\r\n\r\n)
      followed by the data (chunk_split(ba se64encode($dat a)))

      These are the steps you will have to take.

      Good luck!

      Comment

      • bhelsley@interchange.ubc.ca

        #4
        Re: Sending mail with an attachment

        p2 wrote:[color=blue]
        > Hi,
        >
        > I know how to send a file as an attachment when the file is in my file
        > system.
        >
        > Now I want to send data as attachment without saving it to the
        > filesystem first.
        >
        > Under UNIX shell what I do is uuencode and dump the output at the end
        > of the 'data' part of the message.
        >
        > How can I convert the string to an attachment without the mediation of
        > the filesystem?
        >
        > (The goal is to allow users to request data by email)
        >
        > Thank you all,[/color]

        I have a php class (source:
        http://www.ugrad.cs.ubc.ca/~y8r3/code/mailer.html) to handle sending
        multi-part emails with attachments. It does not do what you are
        looking for currently, but the necessary changes are pretty trivial.
        You will, of course, need to know the content-type of your string,
        etc.

        I'm not sure if this will be helpful for you or not, but it might at
        least provide a starting point if you need one.

        -Ben

        Comment

        • p2

          #5
          Re: Sending mail with an attachment

          Thank you all,

          Eventually I did is:

          $mail_msg .= "\nbegin 644 $filename\n";
          $mail_msg .= convert_uuencod e("$string");
          $mail_msg .= "\n`\nend";

          But this work with PHP5 only. The function convert_uuencod e is new.

          Still working on a solution for PHP4.

          Thanks.

          Comment

          • Malcolm Dew-Jones

            #6
            Re: Sending mail with an attachment

            p2 (anonbox@gmail. com) wrote:
            : Thank you all,

            : Eventually I did is:

            : $mail_msg .= "\nbegin 644 $filename\n";
            : $mail_msg .= convert_uuencod e("$string");
            : $mail_msg .= "\n`\nend";

            : But this work with PHP5 only. The function convert_uuencod e is new.

            It also assumes that the mail client does uudecoding. Since uu(en/de)code
            is not a standard, you cannot be sure it will always do what you wish.

            If possible you should use MIME encoding.


            --

            This space not for rent.

            Comment

            Working...