Rumah > pembangunan bahagian belakang > tutorial php > thinkphp 邮件发送_PHP教程

thinkphp 邮件发送_PHP教程

WBOY
Lepaskan: 2016-07-13 10:34:59
asal
1021 orang telah melayarinya

1.下载PHPMailer类包

下载地址

https://code.google.com/a/apache-extras.org/p/phpmailer

注意把文件放在: ThinkPHP/Extend/Vendor/PHPMailer/class.phpmailer.php

2.

<span function</span> SendMail(<span $address</span>,<span $title</span>,<span $message</span><span )
{
    vendor(</span>'PHPMailer.class#PHPMailer'<span );
 
    </span><span $mail</span>=<span new</span><span  PHPMailer();
    </span><span //</span><span  设置PHPMailer使用SMTP服务器发送Email</span>
    <span $mail</span>-><span IsSMTP();
 
    </span><span //</span><span  设置邮件的字符编码,若不指定,则为'UTF-8'</span>
    <span $mail</span>->CharSet='UTF-8'<span ;
 
    </span><span //</span><span  添加收件人地址,可以多次使用来添加多个收件人</span>
    <span $mail</span>->AddAddress(<span $address</span><span );
 
    </span><span //</span><span  设置邮件正文</span>
    <span $mail</span>->Body=<span $message</span><span ;
 
    </span><span //</span><span  设置邮件头的From字段。</span>
    <span $mail</span>->From=C('MAIL_ADDRESS'<span );
 
    </span><span //</span><span  设置发件人名字</span>
    <span $mail</span>->FromName='LilyRecruit'<span ;
 
    </span><span //</span><span  设置邮件标题</span>
    <span $mail</span>->Subject=<span $title</span><span ;
 
    </span><span //</span><span  设置SMTP服务器。</span>
    <span $mail</span>->Host=C('MAIL_SMTP'<span );
 
    </span><span //</span><span  设置为"需要验证"</span>
    <span $mail</span>->SMTPAuth=<span true</span><span ;
 
    </span><span //</span><span  设置用户名和密码。</span>
    <span $mail</span>->Username=C('MAIL_LOGINNAME'<span );
    </span><span $mail</span>->Password=C('MAIL_PASSWORD'<span );
 
    </span><span //</span><span  发送邮件。</span>
    <span return</span>(<span $mail</span>-><span Send());
}
 </span>
Salin selepas log masuk

3. 发送  $this->SendMail("zg@126.cn","title","bodyinfo ");

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/747272.htmlTechArticle1.下载PHPMailer类包 下载地址 https://code.google.com/a/apache-extras.org/p/phpmailer 注意把文件放在: ThinkPHP/Extend/Vendor/PHPMailer/class.phpmailer.php 2. SendMa...
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan