您将如何通过电子邮件实现数据库更新?

时间:2022-12-09 10:06:02

I'm building a public website which has its own domain name with pop/smtp mail services. I'm considering giving users the option to update their data via email - something similar to the functionality found in Flickr or Blogger where you email posts to a special email address. The email data is then processed and stored in the underlying database for the website.

我正在建立一个公共网站,它有自己的域名和pop / smtp邮件服务。我正在考虑让用户通过电子邮件更新他们的数据 - 类似于Flickr或Blogger中的功能,您可以将帖子通过电子邮件发送到特殊的电子邮件地址。然后处理电子邮件数据并将其存储在网站的底层数据库中。

I'm using ASP.NET and SQL Server and using a shared hosting service. Any ideas how one would implement this, or if it's even possible using shared hosting?

我正在使用ASP.NET和SQL Server并使用共享托管服务。任何想法如何实现这一点,或甚至可能使用共享主机?

Thanks

6 个解决方案

#1


3  

For starters you need to have hosting that allows you to create a catch-all mailbox.

对于初学者,您需要拥有允许您创建全能邮箱的托管。

Secondly you need a good POP3 or IMAP library, which is not included AFAIK in the .NET stack.

其次,您需要一个好的POP3或IMAP库,它不包含在.NET堆栈中的AFAIK中。

Then you would write a Command Line application or a Service that regularly checks the mailbox, pulls messages, inserts content in db based on the "To" address (which is unique for each user), and then deletes the email from the mailbox.

然后,您将编写命令行应用程序或服务,定期检查邮箱,提取邮件,根据“收件人”地址(对每个用户唯一)在db中插入内容,然后从邮箱中删除邮件。

It's feasible and sounds like fun. Just make sure you have all you need before you start!

这是可行的,听起来很有趣。在开始之前,请确保您拥有所需的一切!

#2


2  

If the data is somewhat "critical", or at least moderately important, do NOT use their username as the "change-data-address". Example: You might be tempted to create an address like username@domain.com, but instead use username-randomnumer@domain.com where you give them the random number if the visit the web-page. That way people can not update other peoples data just by knowing their username.

如果数据有点“关键”,或者至少是中等重要,请不要将其用户名用作“更改数据地址”。示例:您可能想要创建一个像username@domain.com这样的地址,而是使用username-randomnumer@domain.com,如果访问网页,您可以在其中为其提供随机数。这样人们就无法通过了解用户名来更新其他人的数据。

#3


1  

E-mails can be trivially forged. I would only do this if you can process PGP / SMime certificates in your application.

电子邮件可以简单地伪造。如果您可以在应用程序中处理PGP / SMime证书,我只会这样做。

Other than that, I see no reason why not!

除此之外,我认为没有理由不!

#4


0  

use a dotnet popclient to read the incoming emails, parse them for whatever you are expecting and insert the data into the database.

使用dotnet popclient来读取传入的电子邮件,解析它们以满足您的预期,并将数据插入数据库。

see codeproject website for simple popclient implementation you would have to decided on the email content yourself, eg data only, payload of sql statements, etc

请参阅codeproject网站,了解简单的popclient实现,您必须自己决定电子邮件内容,例如仅限数据,sql语句的有效负载等

#5


0  

You could also identify the user based on sender address. This is how Tripit (and probably others) does it. This only requires one e-mail address on your end.

您还可以根据发件人地址识别用户。这就是Tripit(可能还有其他人)的做法。这只需要一个电子邮件地址。

#6


0  

I have done something similar, using Lumisoft's IMAP client and scheduling a task in my app that checks every x minutes the configured mail address for updates. For scheduling I recommend quartz.net. No launching external processes or anything.

我做了类似的事情,使用Lumisoft的IMAP客户端并在我的应用程序中安排一项任务,每隔x分钟检查一次配置的邮件地址以进行更新。对于日程安排,我推荐quartz.net。没有启动外部流程或任何东西。

#1


3  

For starters you need to have hosting that allows you to create a catch-all mailbox.

对于初学者,您需要拥有允许您创建全能邮箱的托管。

Secondly you need a good POP3 or IMAP library, which is not included AFAIK in the .NET stack.

其次,您需要一个好的POP3或IMAP库,它不包含在.NET堆栈中的AFAIK中。

Then you would write a Command Line application or a Service that regularly checks the mailbox, pulls messages, inserts content in db based on the "To" address (which is unique for each user), and then deletes the email from the mailbox.

然后,您将编写命令行应用程序或服务,定期检查邮箱,提取邮件,根据“收件人”地址(对每个用户唯一)在db中插入内容,然后从邮箱中删除邮件。

It's feasible and sounds like fun. Just make sure you have all you need before you start!

这是可行的,听起来很有趣。在开始之前,请确保您拥有所需的一切!

#2


2  

If the data is somewhat "critical", or at least moderately important, do NOT use their username as the "change-data-address". Example: You might be tempted to create an address like username@domain.com, but instead use username-randomnumer@domain.com where you give them the random number if the visit the web-page. That way people can not update other peoples data just by knowing their username.

如果数据有点“关键”,或者至少是中等重要,请不要将其用户名用作“更改数据地址”。示例:您可能想要创建一个像username@domain.com这样的地址,而是使用username-randomnumer@domain.com,如果访问网页,您可以在其中为其提供随机数。这样人们就无法通过了解用户名来更新其他人的数据。

#3


1  

E-mails can be trivially forged. I would only do this if you can process PGP / SMime certificates in your application.

电子邮件可以简单地伪造。如果您可以在应用程序中处理PGP / SMime证书,我只会这样做。

Other than that, I see no reason why not!

除此之外,我认为没有理由不!

#4


0  

use a dotnet popclient to read the incoming emails, parse them for whatever you are expecting and insert the data into the database.

使用dotnet popclient来读取传入的电子邮件,解析它们以满足您的预期,并将数据插入数据库。

see codeproject website for simple popclient implementation you would have to decided on the email content yourself, eg data only, payload of sql statements, etc

请参阅codeproject网站,了解简单的popclient实现,您必须自己决定电子邮件内容,例如仅限数据,sql语句的有效负载等

#5


0  

You could also identify the user based on sender address. This is how Tripit (and probably others) does it. This only requires one e-mail address on your end.

您还可以根据发件人地址识别用户。这就是Tripit(可能还有其他人)的做法。这只需要一个电子邮件地址。

#6


0  

I have done something similar, using Lumisoft's IMAP client and scheduling a task in my app that checks every x minutes the configured mail address for updates. For scheduling I recommend quartz.net. No launching external processes or anything.

我做了类似的事情,使用Lumisoft的IMAP客户端并在我的应用程序中安排一项任务,每隔x分钟检查一次配置的邮件地址以进行更新。对于日程安排,我推荐quartz.net。没有启动外部流程或任何东西。