function sendemail(){ $mail = new PHPMailer(true); $mail->IsSMTP(); $mail->CharSet='UTF-8'; //设置邮件的字符编码 $mail->SMTPAuth = true; //开启认证 $mail->Port = 25; $mail->Host = "smtp.ym.163.com"; $mail->Username = ""; // $mail->Password = ""; $mail->AddReplyTo("","xiaoxie");//回复地址 $mail->From = ""; $mail->FromName = "谢高升"; $to = "736214763@qq.com"; $mail->AddAddress($to); $mail->Subject = "ceshi "; $mail->Body = '<img src="cid:a.jpg" style="border: none;width:200px;height:200px" />'; $mail->AltBody = "发送图片"; // $mail->AddEmbeddedImage('a.jpg','a.jpg');//当邮件不支持html时备用显示,可以省略 $mail->WordWrap = 80; // 设置每行字符串的长度 $mail->AddAttachment("/var/www/html/sendemail/upload/a.xls"); //可以添加附件 $mail->IsHTML(true); $mail->Send(); }
AddEmbeddedImage 需要的参数$path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream'
如果是链接地址可以直接在img标签直接写;本地的话需要addembeddedimage