如何在php中发送电子邮件正文中的徽标?

如何在php中发送电子邮件正文中的徽标?,php,html,phpmailer,Php,Html,Phpmailer,我附上我的电子邮件代码。我想在我的正文部分中添加一个带有此代码中消息的图像 require_once "../lib/Mail-1.4.1/Mail.php"; $from = 'someone@gmail.com'; $to = $mail; $subject = 'Account Confirmation'; $body = 'Thanks for registering yourself, your login credentials are as follows;'."\r\n".'

我附上我的电子邮件代码。我想在我的正文部分中添加一个带有此代码中消息的图像

require_once "../lib/Mail-1.4.1/Mail.php";

$from = 'someone@gmail.com';
$to = $mail;
$subject = 'Account Confirmation';
$body = 'Thanks for registering yourself, your login credentials are as 
follows;'."\r\n".'Your User Name is: '.$uname.''."\r\n".'Your Password is: 
'.$pass1.'';
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
 );

$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'someone@gmail.com',
'password' => '12345678'
 ));
 $mail = $smtp -> send($to, $headers, $body);

if(PEAR::isError($mail)){
echo '<p>'.$mail->getMessage().'</p>';   
}
else{
   echo "<script>alert('Successfully Registered! Your credentials have been 
sent on email that you have given in the form')</script>";
 }
require_once.“./lib/Mail-1.4.1/Mail.php”;
$fromsomeone@gmail.com';
$to=$mail;
$subject='账户确认';
$body='感谢您的注册,您的登录凭据如下
跟随;'。“\r\n.”您的用户名是:“$uname.”。“\r\n.”您的密码是:
“.$pass1.”;
$headers=数组(
'From'=>$From,
'至'=>$至,
“主题”=>$Subject
);
$smtp=Mail::工厂('smtp',数组(
'主机'=>'ssl://smtp.gmail.com',
“端口”=>“465”,
“auth”=>正确,
'用户名'=>'someone@gmail.com',
“密码”=>“12345678”
));
$mail=$smtp->send($to、$headers、$body);
if(PEAR::isError($mail)){
回显“”。$mail->getMessage()。

”; } 否则{ echo“警报('已成功注册!您的凭据已被删除 通过您以“)”形式提供的电子邮件发送; }

这是我的电子邮件代码,我想在正文中添加一个图像/徽标。

用于嵌入图像
AddEmbeddedImage

您还可以将图像作为内联附件添加到“我的照片”的内容ID中,您可以使用
在HTML正文中访问它

具体而言,以下是添加嵌入式附件的函数:

$mail->addEmbeddedImage($filename, $cid);

你有没有试过先自己做/修复这个问题?你用的是pear mail,不是。你可能想试试。是的,我尝试嵌入图像,但它不工作。我也尝试使用,但代码显示在消息中。@Haris您需要发送
内容类型的标题:text/html
@vivek_23谢谢您的指导,它可以工作了!