所以我有一个像这样的链接:
mailto:[email protected]?subject=Hello%20You&body=Some%20Body%20Text
并且我希望它打开一封邮件,该邮件的图像(理想情况下)嵌入在邮件中或附加到邮件中。理想情况下,我也想将Excel中的表格添加到邮件中。
mailto:[email protected]?subject=Hello%20You&body=Some%20Body%20Text%0A<a%20href="image.jpg"/>
这可能吗?或者我生活在梦想中?
简短答案
不。
长答案
根据RFC2368规范,无法发送图像(作为HTML)
特殊的hname“ body”表示关联的hvalue是消息的主体。“正文”名称应包含消息的第一个文本/纯文本正文部分的内容。mailto URL主要用于生成短文本消息,而这些文本消息实际上是自动处理的内容(例如邮件列表的“订阅”消息),而不是常规的MIME正文。
http://www.ietf.org/rfc/rfc2368.txt
那我该怎么办?
最好的选择是拥有服务器端公式器。
<form action="/pathto/serverside/mailer" method="post">
<input type="text" name="name" placeholder="Your name" />
<input type="text" name="mail" placeholder="Your email-adress" />
<input type="text" name="message" placeholder="Your message" />
<input type="submit" value="Send">
</form>
PHP方式
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $username;
$mail->Password = $password;
$mail->From = $from;
$mail->FromName = $fromName;
$mail->AddAddress($to , $toName);
$mail->Subject = $subject;
$mail->Body = $body; //Your Html
$mail->IsHTML(true);
这基于PHPMailer库https://github.com/PHPMailer/PHPMailer,因为内置mail()
函数本身就是魔鬼;)
ASP方式
MailMessage mail = new MailMessage(from, to, subject, message);
mail.IsBodyHtml = true;
SmtpClient client = new SmtpClient("localhost");
client.Send(mail);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句