BCC在通过MS Exchange从Oracle数据库发送邮件时未正确处理。

huangapple go评论64阅读模式
英文:

BCC not correctly handled when sendin a mail out of an Oracle database via MS Exchange

问题

我通过Oracle数据库通过MS Exchange发送电子邮件。为此,我使用"UTL_SMTP"。但如果我使用"BCC",我看到所有收件人的邮件源中标题保持不变。所以每个人都可以看到谁在密送中。

那里有什么问题吗?在使用BCC时还需要考虑其他事情吗?

这是我的测试代码(带有伪邮件主机):

DECLARE
	p_to        VARCHAR2(255 CHAR) := 'recipient1@test.com';
	p_bcc       VARCHAR2(255 CHAR) := 'recipient2@test.com';
	p_from      VARCHAR2(255 CHAR) := 'no-reply@test.com';
	p_subject   VARCHAR2(255 CHAR) := 'Testmail (BCC)';
	p_message   VARCHAR2(255 CHAR) := 'Testmail BCC.';
	p_smtp_host VARCHAR2(255 CHAR) := 'sm.test.com';
	p_smtp_port NUMBER             := 25;
	
	l_mail_conn UTL_SMTP.connection;
BEGIN
	l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
	
	UTL_SMTP.helo(l_mail_conn, p_smtp_host);
	UTL_SMTP.mail(l_mail_conn, p_from);
	
	UTL_SMTP.rcpt(l_mail_conn,p_to);
	UTL_SMTP.rcpt(l_mail_conn,p_bcc);
	
	UTL_SMTP.open_data(l_mail_conn);
	
	UTL_SMTP.write_data(l_mail_conn, 'To: ' || p_to || UTL_TCP.crlf);
	UTL_SMTP.write_data(l_mail_conn, 'BCC: ' || p_bcc || UTL_TCP.crlf);
	
	UTL_SMTP.write_data(l_mail_conn, 'From: ' || p_from || UTL_TCP.crlf);
	UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || p_subject || UTL_TCP.crlf);
	
	
	UTL_SMTP.write_data(l_mail_conn, UTL_TCP.crlf);
	UTL_SMTP.write_data(l_mail_conn, p_message || UTL_TCP.crlf || UTL_TCP.crlf);
	UTL_SMTP.close_data(l_mail_conn);

	UTL_SMTP.quit(l_mail_conn);
END;
/

"recipient1@test.com"的电子邮件源:

...
To: <recipient1@test.com>
BCC: <recipient2@test.com>
From: <no-reply@test.com>
Subject: Testmail (BCC)
...

谢谢!
Volker

英文:

I send e-mails from an Oracle database via MS Exchange. For this I use "UTL_SMTP". But if I use "BCC", I see the header unchanged in the mail source of all recipients. So everyone can see who is in BCC.

What's wrong there? Do I have to consider anything else with BCC?

Here is my test code (with pseudo mail host):

DECLARE
	p_to        VARCHAR2(255 CHAR) := 'recipient1@test.com';
	p_bcc       VARCHAR2(255 CHAR) := 'recipient2@test.com';
	p_from      VARCHAR2(255 CHAR) := 'no-reply@test.com';
	p_subject   VARCHAR2(255 CHAR) := 'Testmail (BCC)';
	p_message   VARCHAR2(255 CHAR) := 'Testmail BCC.';
	p_smtp_host VARCHAR2(255 CHAR) := 'sm.test.com';
	p_smtp_port NUMBER             := 25;
	
	l_mail_conn UTL_SMTP.connection;
BEGIN
	l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
	
	UTL_SMTP.helo(l_mail_conn, p_smtp_host);
	UTL_SMTP.mail(l_mail_conn, p_from);
	
	UTL_SMTP.rcpt(l_mail_conn,p_to);
	UTL_SMTP.rcpt(l_mail_conn,p_bcc);
	
	UTL_SMTP.open_data(l_mail_conn);
	
	UTL_SMTP.write_data(l_mail_conn, 'To: ' || p_to || UTL_TCP.crlf);
	UTL_SMTP.write_data(l_mail_conn, 'BCC: ' || p_bcc || UTL_TCP.crlf);
	
	UTL_SMTP.write_data(l_mail_conn, 'From: ' || p_from || UTL_TCP.crlf);
	UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || p_subject || UTL_TCP.crlf);
	
	
	UTL_SMTP.write_data(l_mail_conn, UTL_TCP.crlf);
	UTL_SMTP.write_data(l_mail_conn, p_message || UTL_TCP.crlf || UTL_TCP.crlf);
	UTL_SMTP.close_data(l_mail_conn);

	UTL_SMTP.quit(l_mail_conn);
END;
/

E-mail source of "recipient1@test.com":

...
To: <recipient1@test.com>
BCC: <recipient2@test.com>
From: <no-reply@test.com>
Subject: Testmail (BCC)
...

Thanks!
Volker

答案1

得分: 1

我发现,我不应该设置BCC标头。BCC只能与rcpt()函数一起发送。

我在这里找到了解决方案。答案说:“...例如,发送BCC很简单--只需RCPT该人员,而不要将其放在CC:或TO:记录中...”。这就是问题所在,我设置了一个“BCC”标头。在RFC中,我找到了“BCC”标头,所以我添加了它,不幸的是。

最好的,Volker

英文:

Well, after googling again for an hour I found out, that I must not set the BCC header. BCC must only be sent with rcpt() function.

I found the solution here. The answer sais "... For example, sending a BCC is simple -- you just RCPT the person and DON"T put them in a CC: or TO: record. ...". And that was the problem, I was setting a "BCC" header. In the RFCs I found the header "BCC", so I added it, unfortunately.

Best, Volker

huangapple
  • 本文由 发表于 2023年6月15日 18:16:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76481492.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定