qq邮件源码发送php源码

qq邮件源码发送php源码

function sendmail($to,$subject,$body,$from,$fromname,$smtpserver,$smtpuser,$smtppass,$smtpport,$smtpssl,$mailtype,$cc,$bcc,$replyto,$replytoname,$charset,$encoding,$attachments){
require_once("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = $smtpserver;
$mail->Port = $smtpport;
$mail->Username = $smtpuser;
$mail->Password = $smtppass;
$mail->From = $from;
$mail->FromName = $fromname;
$mail->CharSet = $charset;
$mail->Encoding = $encoding;
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$mail->IsHTML($mailtype);
$mail->AddAddress($to);
if(is_array($cc)){
foreach ($cc as $tocc){
$mail->AddCC($tocc);
}
}
if(is_array($bcc)){
foreach ($bcc as $tobcc){
$mail->AddBCC($tobcc);
}
}
if(is_array($attachments)){
foreach ($attachments as $file){
is_file($file) && $mail->AddAttachment($file);
}
}
$mail->AddReplyTo($replyto,$replytoname);
return $mail->Send() ? true : $mail->ErrorInfo;
}

你可能感兴趣的:(php,开发语言)