如何使用phpmailer() [英] how to use phpmailer()

查看:55
本文介绍了如何使用phpmailer()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用phpmailer()发送包含图像的html电子邮件.我已经尽我所知尝试了所有可能的方法,但似乎无法完成.这是我正在使用的代码:


How do I use phpmailer() to send an html email containing an image. I''ve tried every possible way I know but can''t seem to get it done. This is the code I am using:


require("class.phpmailer.php");

$msg = $_POST['msg'];
$subject = $_POST['subject'];


$mail = new PHPMailer();
#$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "branddesignexpress.com/cpanel";
$mail->SMTPAuth = true;
$mail->Username = 'admin@example.com';
$mail->Password = 'xxxxxx';

$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";
$mail->Sender="mailer@example.com";
$mail->AddReplyTo("replies@example.com", "Replies for my site");

$mail->AddAddress("plasteezy@yahoo.com");
$mail->Subject = $subject;

$mail->IsHTML(true);
$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier logoimg
$mail->Body = $msg;
$mail->AltBody="This is text only alternative body.";

if(!$mail->Send())
{
   echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
   echo "Letter is sent";
}





我总是收到以下错误:SMTP错误:无法连接到SMTP主机.发送错误:SMTP错误:无法连接到SMTP主机.





I always get the following error: SMTP Error: Could not connect to SMTP host. Error sending: SMTP Error: Could not connect to SMTP host.

推荐答案

msg =
msg =


_POST [' msg'];
_POST['msg'];


主题 =
subject =


这篇关于如何使用phpmailer()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆