使用SMTP服务器发送BCC电子邮件? [英] Sending BCC emails using a SMTP server?

查看:580
本文介绍了使用SMTP服务器发送BCC电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在某些代码中记录了一段时间:

  / ** 
*添加BCC。
*
*请注意,根据SMTP协议的约定,所有
*地址(包括BCC地址)都包含在每个电子邮件中,因为
*通过Internet发送。 BCC地址只能在目标电子邮件服务器上被剥离。
*
* @param string $ email
* @param string $ name
* @return对象电子邮件
* /

我不记得我从哪里得到了(可能的来源),但这不应该与这个问题有关。基本上,每当我尝试通过SMTP发送带有BCC的电子邮件时,BCC地址都不会隐藏 - 我已经阅读了SMTP协议的整个RFC(几年前),我不认为我没有任何东西。 / p>

奇怪的是,如果我使用 内置 mail()功能 一切正常,我没有想法为什么 - 我想滚动自己的电子邮件发件人,但我不明白这一点。



有人可以在这个黑暗的主题中散发光线吗?

解决方案

BCC地址在目标电子邮件服务器上没有被剥离。这不是它的工作原理。



SMTP实际工作原理




  • 发件人将向SMTP服务器发送 RCPT TO 命令的列表,每个接收者电子邮件地址一个,并且该命令不区分接收器是否为普通的To,CC或BCC类型接收器。

  • 在调用指示SMTP服务器谁是发件人,谁是服务器以及其他所有人的命令后不久,只有发件人才会调用 DATA 命令,其中将包含电子邮件的内容,包括电子邮件标头和正文 - 电子邮件客户端接收的内容。在这些电子邮件标题中通常是从地址到地址,CC地址。

  • BCC地址不会显示给接收者,只是因为它没有打印在 DATA 命令,而不是因为目标SMTP服务器将其剥离。目的地SMTP服务器将仅引用应该接收电子邮件内容的电子邮件地址列表的 RCPT TO 。它不是真的关心收件人是否在To,CC或BCC列表。

    更新(澄清): BCC电子邮件地址必须列在 RCPT TO 命令列表,但BCC标题应打印在 DATA 命令下。



引用我认为与您的案例相关的RFC的一部分:


请注意,邮件数据包括备忘录头项目,如日期,主题,收件人,抄送,[2]。




自己发送电子邮件发送者



几年前,坦白说,相当长的时间假设你还记得结束 - RFC 821 的结尾。 :)


I've had this noted down on some of my code for a while:

/**
 * Add a BCC.
 *
 * Note that according to the conventions of the SMTP protocol all
 * addresses, including BCC addresses, are included in every email as it
 * is sent over the Internet. The BCC addresses are stripped off blind
 * copy email only at the destination email server.
 *
 * @param string $email
 * @param string $name
 * @return object Email
 */

I don't remember where I got it from (possible source) but that shouldn't be relevant to this question. Basically, whenever I try to send an email with BCCs via SMTP the BCC addresses are not hidden - I've read the whole RFC for the SMTP protocol (a couple years ago) and I don't think I'm missing anything.

The strange thing is, if I send an email with BCCs using the built-in mail() function everything works just right and I've no idea why - I would like to roll my own email sender but I fail to understand this.

Can someone please shed some light into this dark subject?

解决方案

The BCC addresses are not stripped off at the destination email server. That's not how it works.

How SMTP actually works

  • The sender will send a list of RCPT TO commands to the SMTP server, one for each receiver email addresses, and this command does not distinguish whether the receiver is a normal To, CC or BCC type receiver.
  • Soon enough after calling the command that tells the SMTP server who's the sender, who's the server, and everything else, only then the sender will call the DATA command, in which will contain the content of the email - which consist of the email headers and body - the one that are received by email clients. Among these email headers are the usual from address, to address, CC address.
  • The BCC address is not shown to the receiver, simply because it's not printed out under the DATA command, not because the destination SMTP server stripped them away. The destination SMTP server will just refer to the RCPT TO for the list of email addresses that should receive the email content. It does not really care whether the receiver is in the To, CC or BCC list.
    Update (to clarify): BCC email addresses must be listed in the RCPT TO command list, but the BCC header should not be printed under the DATA command.

Quoting a part of the RFC that I think is relevant to your case:

Please note that the mail data includes the memo header items such as Date, Subject, To, Cc, From [2].

Rolling out your own email sender

A couple of years ago, I frankly think, is quite a long time back to assume that you still memorize end-to-end of RFC 821. :)

这篇关于使用SMTP服务器发送BCC电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆