Now let's take a look at the mail function mail tutorial in php. if you want to use the mail function normally, we have to configure the parameters in phpini. & lt ;? Php defines the boundary line $ bounda
Now let's take a look at the mail function mail tutorial in php. if you want to use the mail function normally, you have to configure the parameters in php. ini.
-
- // Define the border
- $ Boundary = uniqid ("");
- // Generate the mail header
- $ Header = "From: $ fromnContent-type: multipart/mixed;
- Boundary = "$ boundary" nX-Mailer: PHPnX-Priority: 3 ";
- // Obtain the MIME type of the attachment file
- $ Mimetype = mime_content_type('test.zip ')
- // Obtain the attachment file name
- $ Attach = 'test.zip'
- // Encode and split the attachment file
- $ Fp = fopen ($ attach, "r ");
- $ Content = fread ($ fp, filesize ($ attach ));
- $ Content = chunk_split (base64_encode ($ content ));
- // Generate the email subject
- $ Body ="
- -- $ Boundary
- Content-type: text/plain; charset = iso-8859-1
- Content-transfer-encoding: 8bit
- $ Message
- -- $ Boundary
- Content-Type: $ mimeType; name = $ filename
- Content-Disposition: attachment; filename = $ filename
- Content-Transfer-Encoding: base64
- $ Content
- -- $ Boundary --";
- // Send an email
- Mail ($ to, $ subject, $ body, $ header );
- ?>