如何在电子邮件正文中嵌入图像?
How can I embed and image in email body?
我的代码在下面所以我想知道我可以在正文中做什么来发送带有图片的邮件?
include('SMTPconfig.php');
include('SMTPclass.php');
$from ="pilotn@ann7.com";
$to =$email;
$subject="Your new password";
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "Dear $name\n\n".
"You are invited to register for SATY2015 RSVP log in to http://www.ann7.com/saty2015/index.php to register.\n\n".
"Your username is: $email\n\n".
"Your password is: $pass\n\n";
$headers = "From: $from \r\n";
$headers .= "Reply-To: $from \r\n";
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $to, $subject, $body, $headers);
$SMTPChat = $SMTPMail->SendMail();
if($SMTPChat)
{
$msg="<font color='#63a634'>An email has been sent containing login information. </font>";
}
else
{
$msg="The error occured and your email has not sent containing the information.";
}
在变量中包含代码 HTML,如下所示:
include('SMTPconfig.php'); include('SMTPclass.php');
$from ="pilotn@ann7.com"; $to =$email;
$subject="Your new password";
$theImage="<img src='http://yourdomain.com/yourimage.jpg'>";
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "Dear $name\n\n". "$theImage You are invited to register for SATY2015 RSVP log in to http://www.ann7.com/saty2015/index.php to register.\n\n". "Your username is: $email\n\n". "Your password is: $pass\n\n";
$headers = "From: $from \r\n"; $headers .= "Reply-To: $from \r\n";
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $to, $subject, $body, $headers);
$SMTPChat = $SMTPMail->SendMail(); if($SMTPChat) { $msg="An email has been sent containing login information. "; } else { $msg="The error occured and your email has not sent containing the information."; }
我的代码在下面所以我想知道我可以在正文中做什么来发送带有图片的邮件?
include('SMTPconfig.php');
include('SMTPclass.php');
$from ="pilotn@ann7.com";
$to =$email;
$subject="Your new password";
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "Dear $name\n\n".
"You are invited to register for SATY2015 RSVP log in to http://www.ann7.com/saty2015/index.php to register.\n\n".
"Your username is: $email\n\n".
"Your password is: $pass\n\n";
$headers = "From: $from \r\n";
$headers .= "Reply-To: $from \r\n";
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $to, $subject, $body, $headers);
$SMTPChat = $SMTPMail->SendMail();
if($SMTPChat)
{
$msg="<font color='#63a634'>An email has been sent containing login information. </font>";
}
else
{
$msg="The error occured and your email has not sent containing the information.";
}
在变量中包含代码 HTML,如下所示:
include('SMTPconfig.php'); include('SMTPclass.php');
$from ="pilotn@ann7.com"; $to =$email;
$subject="Your new password";
$theImage="<img src='http://yourdomain.com/yourimage.jpg'>";
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "Dear $name\n\n". "$theImage You are invited to register for SATY2015 RSVP log in to http://www.ann7.com/saty2015/index.php to register.\n\n". "Your username is: $email\n\n". "Your password is: $pass\n\n";
$headers = "From: $from \r\n"; $headers .= "Reply-To: $from \r\n";
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $to, $subject, $body, $headers);
$SMTPChat = $SMTPMail->SendMail(); if($SMTPChat) { $msg="An email has been sent containing login information. "; } else { $msg="The error occured and your email has not sent containing the information."; }