I often hear the question: "I have a contract from the website." How do I add an attachment to an e-mail message sent through a form? "The first thing I want to say is that there is no easy way to do this." You have a good understanding of PHP or other server-side scripting languages. And of course you want an account for a website that really supports PHP. If this is the case, you can send an email with an attachment in PHP after you've finished reading this chapter.
1. How the Attachment Works
If you've ever searched for an "attachment" function in the PHP manual, the result may be nothing (at least not at the time I wrote this article). Later you will spend a lot of time to understand this knowledge.
You might think that when you send an email with an attachment to someone, the attachment is placed in the recipient's mailbox with the message (for example, if you send him or her a PNG picture file, his/her mailbox will contain a TXT file (e-mail) and a. png file (attachment)). But that's not how it works. When you add an attachment, your mail program converts the attachment into a plain text file and inserts the text block after the content you write (the actual email). This, when you send everything out, the recipient's mailbox has only a plain text file-a file containing both the attachment and the actual email content.
Here is an example of an email with an attachment (an HTML file). I have highlighted several important lines:
Return-path:
Date:mon, May 2000 19:17:29 +0000
From:someone
To:person
Message-id: <83729KI93LI9214@example.com>
content-type:multipart/mixed; boundary= "396d983d6b89a"
Subject:here ' s The Subject
--396d983d6b89a
Content-type:text/plain; Charset=iso-8859-1
Content-transfer-encoding:8bit
This is the body of the email.
--396d983d6b89a
content-type:text/html; Name=attachment.html
Content-disposition:inline; Filename=attachment.html
Content-transfer-encoding:8bit
The attachment
http://www.bkjia.com/PHPjc/446863.html www.bkjia.com true http://www.bkjia.com/PHPjc/446863.html techarticle I often hear the question: "I have a contract from the website." How do I add an attachment to an e-mail message sent through a form? "The first thing I want to say is to do this ...