Home > Article > Backend Development > Example of sending yahoo emails with phpmailer
This article introduces an example of using phpmailer to send Yahoo emails. Friends in need can refer to it.
Example of sending emails using PHPMailer class: <?php /** * phpmailer应用实例 * 发送yahoo邮件 * edit bbs.it-home.org */ require_once('../class.phpmailer.php'); $mail= new PHPMailer(); $body= "发送邮件成功"; //采用SMTP发送邮件 $mail->IsSMTP(); //邮件服务器 $mail->Host = "smtp.mail.yahoo.com.cn"; $mail->SMTPDebug = 0; //使用SMPT验证 $mail->SMTPAuth = true; //SMTP验证的用户名称 $mail->Username = "********@yahoo.cn"; //SMTP验证的秘密 $mail->Password = "y*********"; //设置编码格式 $mail->CharSet = "utf-8"; //设置主题 $mail->Subject = "测试"; //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; //设置发送者 $mail->SetFrom('*******@yahoo.cn', 'test'); //采用html格式发送邮件 $mail->MsgHTML($body); //接受者邮件名称 $mail->AddAddress("*********@yahoo.com", "test");//发送邮件 if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> You need to introduce the phpmailer class file, download address: PHPMailer email sending class V5.1 download address. |