如果包含冒号,UTL_SMTP.Write_Data 不会发送任何文本
我创建了一个 Oracle 函数来使用 UTL_SMTP 包发送电子邮件。
当使用Write_Data或Data方法时,如果我的文本不包含冒号,则发送的电子邮件将在电子邮件正文中包含输入的文本。
但是,如果文本包含冒号,则该文本不会包含在电子邮件中。
我在网上看到的每个例子似乎都表明这没有问题。知道这可能是什么原因吗?
这有效: 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它可能会被解释为 标头
而不是自己编写,请查看邮件PLCODEBREW 中包含的代码
It may be getting interpreted as a header
Rather than write your own, look at the mail code included in PLCODEBREW
我也有这个问题。
感谢您已升级到 UTL_MAIL - 我的以下发现适用于那些愿意或必须保留 UTL_SMTP 的人。
如果您确保您的短信正文与模式“aaa:...”不匹配,则 utl_smtp.write_data 不会将其解释为标头。如果您的短信正文确实符合此模式,则在您的消息前添加一个空格,或者您可能只想将冒号替换为分号等...您的选择。
您可以使用以下方法来拦截并解决该问题。
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.
我无法让 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.