发送用C#电子邮件,而不SMTP服务器? [英] Sending email with C# without SMTP Server?
问题描述
我想提出一个简单的网站。这是对我的VPS托管到我运行IIS 7,并具有完全访问权限。 DNS是设置和配置,但没有邮件服务器或任何配置。
I am making a simple website. It is hosted on my VPS to which I run IIS 7 and have full access to. DNS is setup and configured but no mail servers or anything are configured.
我希望用户能够通过一个非常简单的表格发送反馈。
I want users to be able to send feedback through a very simple form.
然而,我没有一个SMTP服务器(即我所知道的)。
I however do not have an SMTP server (that I am aware of).
string from = "";
string to = "someemails@hotmail.com";
string subject = "Hi!";
string body = "How are you?";
SmtpMail.SmtpServer = "mail.example.com";
SmtpMail.Send(from, to, subject, body);
我想将消息发送到一个免费的电子邮件帐户,但我不知道怎么样,因为我没有一个SMTP服务器。
I want to send the messages to a free email account but I'm not sure how since I do not have an SMTP server.
有一些其他办法,我能做到吗?或者一些替代(如使用免费的SMPT或东西)
Is there some other way I can do it? Or some alternative (like using a free smpt or something)
感谢
推荐答案
作为一种选择,在你的配置文件,你可以把
As an alternative, in your config file, you could put
<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\somedirectory" />
</smtp>
</mailSettings>
</system.net>
</configuration>
这将导致所有发送的邮件被发送到磁盘的specifiedPickupDirectory,而不必配置SMTP设置。
This will cause all sent mail to be sent to disk in the specifiedPickupDirectory instead of having to configure the SMTP settings.
这篇关于发送用C#电子邮件,而不SMTP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!