Phpmailer Mail class mail send _php tutorial

Source: Internet
Author: User
Tags word wrap
e-Mail Send function We are using a foreign source code of the Mail class, we may have used the Phpmailer mail class is very simple, today to talk about a simple use of the tutorial, there is a need for friends to refer to, as well as other accessories and so on, you can give my opinion oh.

What to note:
1. The character set of the message, $mail->charset = "GB2312"; Specify the character set here! Here I only specify as GB2312 because so Outlook can display the subject of the message normally, I tried to set it to utf-8 but the garbled characters appear under Outlook.
2. If you are sending an HTML-formatted message, remember to also specify
3. If you want to use it for mass mailing, remember to modify the include file functions, such as:
Require ("phpmailer/class.phpmailer.php");
Switch
Require_once ("phpmailer/class.phpmailer.php");
Otherwise, a redefinition of the class is generated.

The code is as follows Copy Code

!--? php
/*******************************
* Author: Li Yingjiang
* Date: 2006-12-7
**************************** /
Require ("phpmailer/class.phpmailer.php");
Function Smtp_mail ($sendto _email, $subject, $body, $extra _hdrs, $user _name) {
$mail = new Phpmailer ();
$mail->issmtp ();//Send via SMTP
$mail->host = "200.162.244.66";//SMTP servers
$mail->smtpauth = t Rue Turn on SMTP authentication
$mail->username = "Yourmail";//SMTP Username Note: Normal mail authentication does not require an @ domain name
$mail->passwo RD = "MailPassword"; SMTP password
$mail->from = "yourmail@cgsir.com";//Sender mailbox
$mail->fromname = "cgsir.com Administrator";//Sender

$mail->charset = "GB2312";//Specify the character set here!
$mail->encoding = "base64";
$mail->addaddress ($sendto _email, "username");//Recipient's mailbox and name
$mail->addreplyto ("yourmail@cgsir.com", " Cgsir.com ");
//$mail->wordwrap =;//set Word wrap
//$mail->addattachment ("/var/tmp/file.tar.gz");//Attachment
//$mail->addattachment ("/tmp/image.jpg", "new.jpg");
$mail->ishtml (TRUE);//Send As HTML
//message subject
$mail->subject = $subject;
Message content
$mail->body = '





Welcome to http://www.bKjia.c0m


Thank you for registering as a member of this site!




';
$mail->altbody = "text/html";
if (! $mail->send ())
{
echo "message sent incorrectly

";
echo "Message error message:". $mail->errorinfo;
Exit
}
else {
echo "$user _name Mail sent successfully!
";
}
}
Parameter description (Sent to, message subject, message content, additional information, user name)
Smtp_mail (' yourmail@cgsir.com ', ' Welcome to cgsir.com! ', ' NULL ', ' cgsir.com ', ' username ');
?>

Need to download Phpmailer file package phpmailer-1.73.tar.gz from the Open source community: http://phpmailer.sourceforge.net/

http://www.bkjia.com/PHPjc/632968.html www.bkjia.com true http://www.bkjia.com/PHPjc/632968.html techarticle e-Mail sending function we are using a foreign source code of the Mail class, we may have used the Phpmailer mail class is very simple, today to talk about the simple use of the tutorial, there is need ...

  • 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.