是否可以在不使用任何实际电子邮件帐户的情况下以编程方式发送电子邮件 [英] Is it possible to send an email programmatically without using any actual email account

查看:47
本文介绍了是否可以在不使用任何实际电子邮件帐户的情况下以编程方式发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在我的游戏中实现报告错误/建议"选项,但是我不太确定如何才能使其正常工作.我没有自己的服务器或任何东西,所以我不能只将用户写的文本发送到那里.

我想出的唯一方法是客户写一条消息,然后我将其发送到我可以阅读的电子邮件帐户.但是,我不希望用户需要通过他们的个人帐户发送报告.我不太确定如何实现这一点,谷歌搜索也没有提出任何好的建议.

我没有做过很多网络方面的事情,所以如果你能一步一步地解释(甚至可能在代码中)这个过程,我真的很感激.

我使用的是 C#,并且正在为 Windows Phone 7 编写游戏.

解决方案

是的,完全可以这样做.从相对低级的角度来看,您需要:

  1. 为您要发送的电子邮件帐户解析 MX(邮件交换器)服务器.
  2. 打开一个到 MX 服务器的套接字.
  3. 发送适当的SMTP 命令 以将电子邮件发送到您的收件人帐户.您基本上可以自由设置从"地址可以是您想要的任意内容.

SMTP 是一种非常简单/人性化的协议,因此手动完成所有这些工作并不费力.同时,还有预建库可以为您处理所有这些(除非可能接收方 MX 服务器的分辨率).

请注意,以这种方式发送的电子邮件更有可能被作为垃圾邮件过滤掉(通常是因为发件人的 IP/主机名不会与您在决定使用的外发电子邮件地址上放置的任何域相匹配).

另请注意,由于您可以设置from"任何地址,您都可以选择询问用户是否要提供其实际联系地址,如果他们愿意,您可以将其设为发件人".地址,以便您在必要时可以真正与他们取得联系.

I'm thinking of implementing "Report a bug/Suggestions" option to my game, however I am not quite sure how I could get that working. I do not have my own server or anything, so I can't just send the text that user has written to there.

The only way I came up with is that the client would write a message and I would send it to an email account where I could read them. However, I do not want that users would need to send the reports through their personal accounts. I am not quite sure how I could implement this and googling didn't bring up any good suggestions.

I haven't done a lot of network stuff, so I'd really appreciate it if you could explain ( possibly even in code ) the process step-by-step.

I am using C# and the game is being programmed for Windows Phone 7.

解决方案

Yes, it is absolutely possible to do that. From a relatively low-level perspective, you need to:

  1. Resolve the MX (mail-exchanger) server for the e-mail account you want to send to.
  2. Open a socket to the MX server.
  3. Send the appropriate SMTP commands to cause the e-mail message to be delivered to your recipient account. You essentially have the freedom to set the "from" address to be any arbitrary thing you want.

SMTP is a very simple/human-friendly protocol, so it's not a massive effort to do all of that by hand. At the same time, there are prebuilt libraries that will handle all of that for you (except possibly the resolution of the recipient's MX server).

Note that emails sent this way are more likely to be filtered out as spam (generally because the sender's IP/hostname is not going to match whatever domain you put on the outgoing e-mail address you decide to use).

Also note that since you can set the "from" address to anything, you have the option of asking the user if they want to provide their actual contact address, and if they do you can make that the "from" address so that you can actually get back in touch with them if necessary.

这篇关于是否可以在不使用任何实际电子邮件帐户的情况下以编程方式发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆