简体   繁体   English

如何将smtp发送功能添加到我的应用程序中

[英]how add smtp send functionality to my application

i have a custom c# app. 我有一个自定义的c#应用程序。 is there a way i can send emails without smtp server. 有没有办法我可以发送没有smtp服务器的电子邮件。 ie have a library that will simuate smtp functionality and send emails to external emails. 即有一个库将模拟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 (ie the recipients' servers). 虽然您可以编写自己的SMTP协议实现,以便实际上充当自己的SMTP服务器(甚至不难),但您仍然必须与其他SMTP服务器(即收件人的服务器)进行交互。 And over the last 10 years or so, a lot of those servers have become less trusting in who they will talk to. 在过去10年左右的时间里,很多服务器已经变得不那么信任他们会与谁交谈。 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. 许多人会进行反向DNS查询,以查看您发送的IP地址是否与您域名的MX记录中列出的IP地址相同。 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. 此外,许多ISP已阻止端口25(由SMTP使用),因此除非通过SMTP服务器,否则无法从其网络发送电子邮件。 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. 因此,您的问题的答案在技术上是肯定的:您可以编写类似SMTP客户端的代码来发送邮件。 But in practical application, that becomes much more difficult due to restrictions imposed by ISPs and the recipient ISPs' SMTP servers. 但在实际应用中,由于ISP和接收方ISP的SMTP服务器施加的限制,这变得更加困难。

If you're interested in writing SMTP code, you might find the following instructive: 如果您对编写SMTP代码感兴趣,可能会发现以下指导:

You could use Amazon's Simple Email Service ( http://aws.amazon.com/ses/ ). 您可以使用亚马逊的简单电子邮件服务( http://aws.amazon.com/ses/ )。 It provides you with and API to send e-mails (low volume or bulk). 它为您提供发送电子邮件(小批量或大量)的API和API。

The service isn't free, but it is very cheap ($0.10 per 1000 e-mails). 该服务不是免费的,但它非常便宜(每1000封电子邮件0.10美元)。 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...). 大多数亚马逊云服务都有一个免费套餐,但只有在您从EC2实例发送电子邮件时才适用(很可能不是您的情况......)。

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 :) 此外,它还为您提供有关可传递性的统计信息,并保证您不会被标记为垃圾邮件(除非您正在做的事情:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM