Php mail function mail tutorial

Source: Internet
Author: User
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.

  1. // Define the border
  2. $ Boundary = uniqid ("");
  3. // Generate the mail header
  4. $ Header = "From: $ fromnContent-type: multipart/mixed;
  5. Boundary = "$ boundary" nX-Mailer: PHPnX-Priority: 3 ";
  6. // Obtain the MIME type of the attachment file
  7. $ Mimetype = mime_content_type('test.zip ')
  8. // Obtain the attachment file name
  9. $ Attach = 'test.zip'
  10. // Encode and split the attachment file
  11. $ Fp = fopen ($ attach, "r ");
  12. $ Content = fread ($ fp, filesize ($ attach ));
  13. $ Content = chunk_split (base64_encode ($ content ));
  14. // Generate the email subject
  15. $ Body ="
  16. -- $ Boundary
  17. Content-type: text/plain; charset = iso-8859-1
  18. Content-transfer-encoding: 8bit
  19. $ Message
  20. -- $ Boundary
  21. Content-Type: $ mimeType; name = $ filename
  22. Content-Disposition: attachment; filename = $ filename
  23. Content-Transfer-Encoding: base64
  24. $ Content
  25. -- $ Boundary --";
  26. // Send an email
  27. Mail ($ to, $ subject, $ body, $ header );
  28. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.