Another solution for PHP under Mail

Source: Internet
Author: User
Tags date end mail
Resolved a period of time before I contacted Dec Tru64 Unix i installed the Php+apache, you can use the mail function provided is always unable to send a letter, and then a function, it uses the pipeline under the Unix and PHP sock function to send letters, after the experiment is very successful in the The following is the original code for this function.
function MyMail ($mto, $MCC, $msubject, $mbody)
{
$from = "webmaster@backhome.com.cn";
$sign = "";/whatever you write.
$sendmailpath = "/usr/lib/sendmail";//semdmail path
$bound = "========_". Uniqid ("Bcfmail"). " ==_ ";//delimiters
$headers = "mime-version:1.0".
"Content-type:multipart/mixed; boundary= "$bound" ".
"Date:". Date ("D, D M h:i:s Y"). " ".
"From: $from".
"To: $mto".
"Cc: $MCC".
"Subject: $msubject".
"Status:".
"X-status:".
"X-mailer:my Email Interface".
"X-keywords:";
$content = "-$bound." "." content-type:text/plain;charset= "GB2312" ". $mbody. $sign." ";
$end = "". " --". $bound." -- ";
$sock = Popen ("$sendmailpath-t-F ' webmaster@backhome.com.cn '", ' w ');
Fputs ($sock, $headers);
Fputs ($sock, $content);
Fputs ($sock, $end);
Fputs ($sock, ".");
Fputs ($sock, "QUIT");
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.