PHP System mail Send function

Source: Internet
Author: User
Tags php class
/** * Function: System mail Send function * @param string $to incoming mail person mailbox * @param string $name Recipient name * @param string $subject message subject * @param str  ing $body Mail content * @param string $attachment Attachment list * @return Boolean */function send_mail ($to, $name, $subject = ', $body    = ', $attachment = null, $config = ') {$config = Is_array ($config)? $config: C (' System_email ');         Import (' Phpmailer.phpmailer ', vendor_path);                           From Phpmailer directory class.phpmailer.php class file $mail = new Phpmailer ();                         Phpmailer object $mail->charset = ' UTF-8 ';                                   Set the message encoding, the default iso-8859-1, if the text must be set in Chinese, otherwise garbled $mail->issmtp ();    Set the SMTP service to use//$mail->ishtml (TRUE);                             $mail->smtpdebug = 0;                           Turn off the SMTP debugging feature 1 = errors and Messages2 = messages only $mail->smtpauth = true;                    Enable the SMTP authentication feature if ($config [' smtp_port '] = = 465) $mail->smtpsecure = ' SSL '; Using the security protocol $mail-&Gt                Host = $config [' Smtp_host '];                SMTP server $mail->port = $config [' Smtp_port '];           The port number of the SMTP server $mail->username = $config [' Smtp_user '];           SMTP Server user name $mail->password = $config [' Smtp_pass '];    SMTP server password $mail->setfrom ($config [' From_email '], $config [' from_name ']); $replyEmail = $config [' Reply_email ']?    $config [' Reply_email ']: $config [' reply_email ']; $replyName = $config [' Reply_name ']?    $config [' Reply_name ']: $config [' reply_name '];    $mail->addreplyto ($replyEmail, $replyName);    $mail->subject = $subject;    $mail->msghtml ($body);    $mail->addaddress ($to, $name);                if (Is_array ($attachment)) {//Add attachment foreach ($attachment as $file) {if (Is_array ($file)) {            Is_file ($file [' path ']) && $mail->addattachment ($file [' Path '], $file [' name ']);            } else {is_file ($file) && $mail->addattachment ($file);    }        }} else {is_file ($attachment) && $mail->addattachment ($attachment); } return $mail->send ()? true: $mail->errorinfo;}
  • 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.