Phpmail class send mail function code _php tips

Source: Internet
Author: User
With the Phpmail class, you don't have to worry about it. This is a class written by a foreigner, we just "copycat". Here is a function written based on the Send () method inside the class:
Copy Code code as follows:

function Send_mail ($title, $content, $from, $to, $charset = ' GBK ', $attachment = ')
{
Include '/class/phpmail.class.php ';
Header (' content-type:text/html charset= '. $charset);
$mail = new Phpmailer ();
$mail->charset = $charset; Set up using gb2312 Chinese code
$mail->issmtp (); To set the SMTP way to send mail
$mail->host = "smtp.qq.com"; Set the address of the mail server
$mail->port = 25; Set the port for the mail server by default of 25
$mail->from = $from; Set the sender's mailbox address
$mail->fromname = ""; Set the sender's name
$mail->smtpauth = true; To set whether SMTP requires password authentication, true indicates the need for
$mail->username = $from; Set up mailboxes to send messages
$mail->password = ""; Set the password for a mailbox
$mail->subject = $title; Set the title of a message
$mail->altbody = "text/html"; Optional, comment out and test
$mail->body = $content; Set up message content
$mail->ishtml (TRUE); Set whether content is HTML type
$mail->wordwrap = 50; Set the number of characters per line
$mail->addreplyto ("Address", "name"); Set the address of the recipient of the reply
$mail->addaddress ($to, "star Model Training"); Set the address of your inbox
if ($attachment!= ')//Set attachment
{
$mail->addattachment ($attachment, $attachment);
}
if (! $mail->send ())
{
return false;
} else {
return true;
}
}

Generally is using QQ mailbox, because QQ mailbox is easy to open SMTP and POP3 service, and free, attention is the content of the message format and coding.
PHPMail.class.php this class, click to download it!

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.