Another solution for mail in PHP

Source: Internet
Author: User

Some time ago I came into contact with DEC Tru64 UNIX. I installed PHP + Apache on it. I could use the provided mail function to send emails normally, so I compiled a function, it uses UNIX pipelines and PHP sock functions to send emails. The experiment was very successful. below is the original function. Code .
Function mymail ($ MTO, $ MCC, $ msubject, $ mbody)
{
$ From = "webmaster@backhome.com.cn ";
$ Sign = "\ n"; // whatever you want
$ Sendmailpath = "/usr/lib/sendmail"; // semdmail path
$ Bound = "=======_". uniqid ("bcfmail"). "==_"; // delimiter
$ Headers = "mime-version: 1.0 \ n ".
"Content-Type: multipart/mixed; boundary = \" $ bound \ "\ n ".
"Date:". date ("D, d m h: I: S Y"). "\ n ".
"From: $ from \ n ".
"To: $ MTO \ n ".
"Cc: $ MCC \ n ".
"Subject: $ msubject \ n ".
"Status: \ n ".
"X-status: \ n ".
"X-mailer: My email interface \ n ".
"X-keywords: \ n ";
$ Content = "--". $ bound. "\ n ". "Content-Type: text/plain; charset = \" gb2312 \ "\ n ". $ mbody. $ sign. "\ n ";
$ End = "\ n". "--". $ bound. "-- \ n ";
$ Sock = popen ("$ sendmailpath-T-F 'webmaster @ backhome.com.cn '", 'w ');
Fputs ($ sock, $ headers );
Fputs ($ sock, $ content );
Fputs ($ sock, $ end );
Fputs ($ sock, ". \ n ");
Fputs ($ sock, "Quit \ n ");
Pclose ($ sock );
}

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.