如何使用 Gmail 和 Java 从不同地址发送邮件?
我正在使用 Java 通过 Apache Commons Email 从 Gmail 发送邮件,但似乎没有不允许我从与我用于身份验证的地址不同的地址发送消息。
如何使用 Gmail 和 Java 从不同地址发送邮件?
I'm using Java to send messages from Gmail with Apache Commons Email, but it seems like it doesn't allow me to send messages from an address different from the one that I use to authenticate.
How do you send messages from a different address using Gmail and Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本上,您正在寻找一个 SMTP 服务器,它可以让您通过欺骗 From MIME 标头来发送消息。那么,如果您无法在线找到托管 SMTP 服务器,您可以随时安装一个本地在您的盒子上。这将允许您修改发件人的电子邮件地址,使其看起来像是来自 gmail。
Basically, you are looking for an SMTP server which will let you send a message by spoofing the From MIME header. Well, if you can't find a hosted SMTP server online, you can always install one locally on your box. This will allow you to modify the email address of the sender to make it appear as if it is coming from gmail.
据我所知你不能。这就是所谓的中继。垃圾邮件发送者利用中继来冒充任何人发送邮件。这是一个安全漏洞。如果您想以其他人的身份发送,则需要创建另一个帐户。
As far as I'm aware you can't. That is what is called relaying. Relaying is what the spammers use to send mail pretending to be whoever. Its a security hole. If you want to send as someone else you need to create another account.
对于 Gmail,您很可能不能……原因显而易见。
在 Java 情况下,是否可以执行此操作取决于 Java 应用程序连接到的邮件服务器。邮件服务器通常可以配置为允许这样做,但它有明显的问题,因此负责任的邮件服务器管理员不会允许这样做,除非在受控情况下。
For gmail, you most likely can't ... for obvious reasons.
In the Java case, whether you can or can't do this depends on the mail server that your Java application connects to. A mail server typically can be configured to allow this, but it has obvious issues so a responsible mail server admin is not going to allow this, except in controlled circumstances.