如果包含冒号,UTL_SMTP.Write_Data 不会发送任何文本

发布于 2024-08-20 06:18:01 字数 435 浏览 7 评论 0原文

我创建了一个 Oracle 函数来使用 UTL_SMTP 包发送电子邮件。

当使用Write_DataData方法时,如果我的文本不包含冒号,则发送的电子邮件将在电子邮件正文中包含输入的文本。

但是,如果文本包含冒号,则该文本不会包含在电子邮件中。

我在网上看到的每个例子似乎都表明这没有问题。知道这可能是什么原因吗?

这有效: UTL_SMTP.write_data(l_mail_conn, 'test');

这不会被发送: UTL_SMTP.write_data(l_mail_conn, 'test:');

也不会: <代码>UTL_SMTP.write_data(l_mail_conn, '测试' || ':');

I have created a Oracle function to send an email using the UTL_SMTP package.

When using the methods Write_Data or Data, if my text does not contain a colon, the sent email will contain the inputted text in the email's body.

However, if the text contains a colon, the text is not included in the email.

Every example of this i've seen online seems to indicate this is no problem. Any idea what could be the cause of this?

This works: UTL_SMTP.write_data(l_mail_conn, 'test');

This does not get sent: UTL_SMTP.write_data(l_mail_conn, 'test:');

nor does: UTL_SMTP.write_data(l_mail_conn, 'test' || ':');

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

記柔刀 2024-08-27 06:18:01

它可能会被解释为 标头

而不是自己编写,请查看邮件PLCODEBREW 中包含的代码

It may be getting interpreted as a header

Rather than write your own, look at the mail code included in PLCODEBREW

公布 2024-08-27 06:18:01

我也有这个问题。
感谢您已升级到 UTL_MAIL - 我的以下发现适用于那些愿意或必须保留 UTL_SMTP 的人。

如果您确保您的短信正文与模式“aaa:...”不匹配,则 utl_smtp.write_data 不会将其解释为标头。如果您的短信正文确实符合此模式,则在您的消息前添加一个空格,或者您可能只想将冒号替换为分号等...您的选择。

您可以使用以下方法来拦截并解决该问题。

.....
/* 999999999 is just an indicitive integer above and beyond the max length of an sms */
     IF (INSTR(p_message,':') < NVL(INSTR(p_message,' '),999999999)
        AND  INSTR(p_message,':') != 0)
     THEN p_message := ' '||p_message;
     END IF;

utl_smtp.write_data(l_mail_conn, p_message);
.....

I had this problem too.
Apreciating that you have upgraded to UTL_MAIL - my findings below are for those whom would prefer or have to stay with UTL_SMTP.

If you ensure your SMS body does not match the pattern 'aaa:...' then the utl_smtp.write_data will not interpret it as a header. If your SMS body does match this pattern then prefix your message with a space or you may simply want to replace the colon with a semi-colon etc... Your choice.

You can use the following to intercept and workaround the problem.

.....
/* 999999999 is just an indicitive integer above and beyond the max length of an sms */
     IF (INSTR(p_message,':') < NVL(INSTR(p_message,' '),999999999)
        AND  INSTR(p_message,':') != 0)
     THEN p_message := ' '||p_message;
     END IF;

utl_smtp.write_data(l_mail_conn, p_message);
.....
仙女 2024-08-27 06:18:01

我无法让 UTL_SMTP 工作 - 当然看起来 UTL_SMTP 正文中的任何冒号都被解释为标头,并且我找不到转义它们的方法。

我能够使用Oracle在10g中引入的UTL_MAIL包并且它运行得很好。唯一需要的配置是将 oracle 中的 smtp_out_server 变量设置为邮件服务器的邮件服务器(包括端口号)。仅需要单个方法调用 - 在 PL/SQL 中实现也更加清晰 - 并且还允许您更好地控制特定电子邮件字段(例如主题),并且还可以处理附件。

I wasn't able to get UTL_SMTP working - certainly looks like any colons in the UTL_SMTP body was being interpreted as a header and I could not find a way to escape them.

I was able to use the UTL_MAIL package introduced by Oracle in 10g and it worked very well. Only configuration necessary was setting the smtp_out_server variable in oracle to the mail server (include the port number)of the mail server. Only requires a single method call - much cleaner to implement in PL/SQL as well - and also allows you more control over specific email fields (Subject, for example) and can handle attachments as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文