如何向我的应用程序添加 smtp 发送功能

发布于 2024-10-17 14:56:51 字数 89 浏览 11 评论 0原文

我有一个自定义的 C# 应用程序。有没有一种方法可以在没有 smtp 服务器的情况下发送电子邮件?即有一个库可以模拟 smtp 功能并将电子邮件发送到外部电子邮件。

i have a custom c# app. is there a way i can send emails without smtp server. ie have a library that will simuate smtp functionality and send emails to external emails.

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

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

发布评论

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

评论(2

梦太阳 2024-10-24 14:56:51

虽然您可以编写自己的 SMTP 协议实现,以便实际上充当您自己的 SMTP 服务器(这甚至不难做到),但您仍然必须与其他 SMTP 服务器(即收件人的服务器)进行交互。在过去 10 年左右的时间里,许多服务器变得越来越不信任他们将与谁交谈。许多人会进行反向 DNS 查找,以查看您发送的 IP 地址是否与您域名的 MX 记录中列出的 IP 地址相同。如果不匹配,服务器将拒绝接受您的邮件。

此外,许多 ISP 已阻止端口 25(由 SMTP 使用),因此您无法从他们的网络发送电子邮件,除非通过他们的 SMTP 服务器。这可以防止客户使用家庭高速连接发送垃圾邮件。 (至少,这使事情变得更加困难。)

因此,从技术上讲,您的问题的答案是肯定的:您可以编写类似于 SMTP 客户端的代码来发送邮件。但在实际应用中,由于 ISP 和收件人 ISP 的 SMTP 服务器施加的限制,这变得更加困难。

如果您对编写 SMTP 代码感兴趣,您可能会发现以下内容具有指导意义:

Whereas you could write your own SMTP protocol implementation so that you in effect act as your own SMTP server (it's not even difficult to do), you still have to interface with other SMTP servers (i.e. the recipients' servers). And over the last 10 years or so, a lot of those servers have become less trusting in who they will talk to. Many will do reverse DNS lookups to see if the IP address you're sending from is the same as the IP address listed in the MX record for your domain name. If they don't match, the server will refuse to accept mail from you.

Furthermore, many ISPs have blocked port 25 (used by SMTP) so that you can't send email from their networks except by going through their SMTP servers. That prevents customers from using their home high speed connections to send out spam. (At least, it makes things more difficult.)

So, the answer to your question is technically yes: you could write code that acts like an SMTP client to send mail. But in practical application, that becomes much more difficult due to restrictions imposed by ISPs and the recipient ISPs' SMTP servers.

If you're interested in writing SMTP code, you might find the following instructive:

情栀口红 2024-10-24 14:56:51

您可以使用 Amazon 的简单电子邮件服务 (http://aws.amazon.com/ses/)。它为您提供 API 来发送电子邮件(少量或批量)。

该服务不是免费的,但非常便宜(每 1000 封电子邮件 0.10 美元)。与大多数 Amazon 云服务一样,有一个免费套餐,但此套餐仅适用于您从 EC2 实例发送电子邮件的情况(很可能不是您的情况……)。

此外,它还为您提供有关送达率的统计数据,并保证您不会被标记为垃圾邮件(除非您正在这样做:)

You could use Amazon's Simple Email Service (http://aws.amazon.com/ses/). It provides you with and API to send e-mails (low volume or bulk).

The service isn't free, but it is very cheap ($0.10 per 1000 e-mails). There is a free tier like in most Amazon cloud services, but this one is only applicable if you are sending the e-mails from EC2 instances (most likely not your case...).

Additionally it provides you with statistics on deliverability and some assurance that you won't get flagged as spam (unless that's what you are doing :)

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