html - 将 html 功能添加到 utl_smtp 未显示在 gmail 中,但在另存为 .html 文件并在浏览器中打开时显示

标签 html database oracle plsql gmail

下面是我的代码。我可以发送到我的电子邮件地址,但邮件只显示我的整个 html 代码。但是,当我将其保存为html文件并在浏览器中打开时,它能够正常显示。似乎是什么问题? gmail 支持 html 吗?

UTL_SMTP.write_data(mail_conn, 'MIME-Version: 1.0' || UTL_TCP.crlf);
UTL_SMTP.write_data(mail_conn, 'Content-Type: multipart/alternative; boundary="' || l_boundary || '"' || UTL_TCP.crlf || UTL_TCP.crlf);
  IF p_message IS NOT NULL THEN
UTL_SMTP.write_data(mail_conn, '--' || l_boundary || UTL_TCP.crlf);
UTL_SMTP.write_data(mail_conn, 'Content-Type: text/plain; charset="iso-8859-1"' || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(mail_conn, p_message);
UTL_SMTP.write_data(mail_conn, UTL_TCP.crlf || UTL_TCP.crlf);
  END IF;
  IF p_html_message IS NOT NULL THEN
UTL_SMTP.write_data(mail_conn, '--' || l_boundary || UTL_TCP.crlf);
UTL_SMTP.write_data(mail_conn, 'Content-Type: text/html; charset="iso-8859-1"' || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(mail_conn, p_html_message);
UTL_SMTP.write_data(mail_conn, UTL_TCP.crlf || UTL_TCP.crlf);
  END IF;
UTL_SMTP.write_data(mail_conn, '--' || l_boundary || '--' || UTL_TCP.crlf);
utl_smtp.close_data(mail_conn);
utl_smtp.quit(mail_conn);
p_returnCode :=0;
EXCEPTION
WHEN OTHERS THEN
  p_returnCode :=SQLCODE;
  p_err_msg :=SQLERRM;
END;

这就是我对包裹的称呼。

 DECLARE
 l_html VARCHAR2(32767);
 BEGIN
 l_html := '<html>
 <head>
 <title>Test HTML message</title>
 </head>
 <body>
 <p>This is a <b>HTML</b> <i>version</i> of the test message.</p>
 <p><img src="http://oracle-base.com/images/site_logo.gif" alt="Site Logo"     />
</body>
[![enter image description here][1]][1]</html>';
SENDMAIL('my@gmail.com', 'This is a test message', l_html);
END;

下图是我将代码保存为html文件并在浏览器中显示的图片。 enter image description here enter image description here 上图是我的 gmail 收件箱中显示的内容。

最佳答案

您的代码告诉服务器您发送的消息是文本,因此它会将其显示为文本。

'Content-Type: text/plain; charset="iso-8859-1"'

尝试告诉它它的 html。

Content-Type: text/html; charset=UTF-8

关于html - 将 html 功能添加到 utl_smtp 未显示在 gmail 中,但在另存为 .html 文件并在浏览器中打开时显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41180430/

相关文章:

javascript - ajax成功后保存输入数据并在文本框中添加图标

html - 背景图像结束时较大显示器上的空白

php - ZF2 ResultSet 和计数性能

php - 尝试通过 php 将日期插入 Oracle 数据库,但代码无法正常工作

java - Spring Integration 轮询多个服务器上的入站 channel 适配器

html - 为什么 Inline-block 没有按照我的预期进行?

javascript - 使用 jQuery 修改 html 属性会产生意外结果

mysql - 在使用过程中备份数据库有什么危险?

php - sql查询在执行第一行后停止

sql - 复合外键 - 在 Oracle 中可能吗?