使用 C# 自动创建电子邮件地址并接收电子邮件?

发布于 2024-10-10 11:46:29 字数 455 浏览 5 评论 0原文

我非常喜欢Backpack 中提供的电子邮件功能,它为每个背包页面创建一个唯一的电子邮件地址,发送到该地址的任何电子邮件都将发布到该页面。

我的问题是如何最好地自动创建新的电子邮件地址,并侦听发送到这些地址的新电子邮件。我想从 C# 服务执行此操作(我没有使用 ASP.Net)

  • 有没有人尝试实现此目的或 之前有类似的事情吗?
  • 有没有图书馆(最好是 FLOSS)已经可用,可以做 这或者会对我有帮助吗?
  • 是否可以使用基于云的技术来做到这一点 电子邮件服务(如果有,是什么服务?)和 用于与之通信的库 服务(OpenPop.Net 或类似服务)?

I'm a big fan of the email feature available in Backpack, where it creates a unique email address per backpack page, and any emails sent to that address will be posted to the page.

My question is about how best to go about creating new email addresses automatically, and listening for new emails sent to those addresses. I'd like to do this from a C# service (I'm not using ASP.Net)

  • Has anyone tried to achieve this or
    something similar before?
  • Are there libraries (preferably
    FLOSS) already available which do
    this or would assist me?
  • Is it possible to do this using a cloud-based
    email service (and if so, what service?) and a
    library for communicating with that
    service (OpenPop.Net or similar)?

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

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

发布评论

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

评论(3

独闯女儿国 2024-10-17 11:46:29

如果您的电子邮件提供商支持在您的域上设置通配符电子邮件,那么您可以使用单个电子邮件帐户来执行此操作。

例如,Google Apps for Domains 允许将 *@example.com 设置为传送到 [电子邮件受保护]。当有人发送电子邮件 [email protected] 或 < code>[email protected] 它将全部发送到[电子邮件受保护]

然后就是获取所有电子邮件的过程。然后,您查看电子邮件中的 to 标头,将其与应用程序中存储的该用户的名称进行匹配,然后按照您的意愿进行处理。

请注意,使用此方法时您会收到垃圾邮件和其他地址错误的电子邮件。您必须自己处理这些问题(例如,丢弃未发送至有效帐户的错误邮件)。

If your email provider supports setting up wildcard email on your domain, then you can do this with a single email account.

For example, Google Apps for Domains allows setting *@example.com to be delivered to [email protected]. When someone emails [email protected] or [email protected] it will all be delivered to [email protected].

Then it's a process of getting all the emails. You then look at the to header in the email, match that with the name stored in your application for that user, and then process however you wish.

Be aware that you will get spam and other incorrectly addressed emails when you use this method. You will have to deal with these yourself (eg by discarding incorrectly mail that isn't addressed to a valid account).

青芜 2024-10-17 11:46:29

我没有对传入的邮件进行过多的研究,但从顶层来看,这是你应该做的。

  • 根据任意逻辑为用户创建电子邮件地址并将其保存在数据库中。

  • 使用您的域名设置邮件服务器,并将一个电子邮件帐户设置为“包罗万象”的邮件帐户。如果找不到电子邮件地址,发送到您的域的任何邮件都将被捕获在该邮件帐户下。

  • 创建一个 Windows 服务,该服务将从该“Catch-All”帐户读取邮件。有几个库可用于使用 POP3 或 IMAP 读取邮件。

  • 读取传入邮件以检查其发送到的电子邮件地址,将其与数据库中存储的值进行比较并进行相应处理。

检查这个问题。它可能会帮助您阅读传入邮件

I haven't played around much with incoming mails, but from the top level here is what you should do.

  • Create email addresses for the users based on any logic and save it in the DB.

  • Setup a mail server with your domain name and set one email account as a "catch-all" mail account. Any mail sent to your domain would then be caught under that mail account, in case the email address is not found.

  • Create a windows service, that would read mails from that "Catch-All" account. There are several libraries available to read mails using POP3 or IMAP.

  • Read the incoming mails to check the email address it was sent to, compare it with the values stored in the DB and process accordingly.

Check this question. it might help you with reading incoming mails.

泅人 2024-10-17 11:46:29

目标不是创建电子邮件地址,这实际上并没有发生。您所做的就是在系统中接受电子邮件地址,接受什么取决于您。您可以设置邮件服务器来接收发送到您的域的任何电子邮件,然后可以解析电子邮件“收件人”字段并提取“名称”部分。如果它与您正在收听的内容匹配,那么您就会采取相应的行动。

我认为您不会找到适合此特定活动的图书馆,因为它相当孤立。有很多直接或间接接收电子邮件并在 C# 中处理它们的方法,但我不会介绍这些,因为 .Net 中的邮件处理已有详细记录。

The objective isn't to create email addresses, that doesn't really happen. What you do is accept email addresses at your system, what you accept is up to you. You could set up a mail server to receive any email sent to your domain, you could then parse the email To field and extract the 'name' portion. If it matches something you are listening for then you action it accordingly.

I don't think you'll find a library for this specific activity as it's rather insular. There are plenty of ways of receiving emails directly or indirectly and processing them in C# but I won't cover that as mail handling in .Net is well documented.

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