如何发送接收者无法回复的电子邮件 [英] How to Send EMail that receiver can't reply

查看:189
本文介绍了如何发送接收者无法回复的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为标题。我正在开发一个能够向会员发送带附件的电子邮件的系统。我希望接收方无法回复收到的电子邮件,因为发件人的电子邮件地址可能是虚拟的,就像某些电子邮件中包含此电子邮件是由系统自动发送的,请不要回复。

我想要建立这个功能,但我发现没有第三方组件很难,而且价格昂贵。我尝试了一些示例代码,其中一个如下所示:

As title. I am developing a system that is able to send email with attachments to members. I want the receivers can't reply the received email because the sender email address may be virtual , like some email that contains "this email is sent by the system automatically, please do not reply."
I want to build this function but I found it is hard without 3rd party components, and those are expensive. I've tried some sample codes, one of this is like the below:

public string SendEMail(string From,string To,string Subject,string Content)
        {
            try
            {
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                msg.To.Add(To);
                msg.From = new MailAddress(From, From, System.Text.Encoding.UTF8);

                msg.Subject = Subject; 
                msg.SubjectEncoding = System.Text.Encoding.UTF8; 
                msg.Body = Content; 
                msg.BodyEncoding = System.Text.Encoding.UTF8; 
                msg.IsBodyHtml = false; 
                msg.Priority = MailPriority.Normal;

                SmtpClient client = new SmtpClient();
                //client.Credentials = new System.Net.NetworkCredential(SenderAddress, SenderPassword);
                client.Host = "localhost";
                //client.EnableSsl = true;

                client.Send(msg);
                return string.Empty;
            }
            catch (Exception ex)
            {
                return "Exception:" + ex.Message + "Stacktrace:" + ex.StackTrace;
            }
        }



但我得到了发送电子邮件失败。执行此代码时出现异常消息。我怎么能得到它?


But I got the "Send EMail fail." exception message while executing this code. How could I get it?

推荐答案

你有一些问题。首先,您无法控制您正在使用的邮件服务器,除非您自己设置了一个邮件服务器。这意味着您将受到用于发送电子邮件的邮件服务器上的策略设置的支配。不,没有一个你不能做任何事情。



这意味着如果邮件服务器的所有者说它不发送或转发没有发件人的电子邮件地址,你必须把它放入。如果所有者说电子邮件地址必须与发送电子邮件的帐户匹配,你必须将你的电子邮件地址放在发件人字段。



我工作的地方,如果没有填写发件人地址,就无法发送和发送电子邮件。它不一定是有效的帐户。它只需要填写。



现在您已经将电子邮件发送到发送邮件的服务器上,您没有打败这些问题。如果未填写发件人,某些服务器甚至不会发送电子邮件。因此,将该字段留空可能不适用于所有收件人。



最好的方法做你想要的只是创建一个电子邮件地址(它通常不存在!),说noreply@yourdomain.com或类似的东西。如果用户回复电子邮件,那就是他们的问题,而不是你的问题。如果电子邮件帐户不存在,他们的电子邮件将无法送达。在最坏的情况下,它将位于帐户的收件箱中,该帐户无人监控并最终被服务器删除。
You have a few problems. First, you have no control over the mail server you're using unless you set one up yourself. This means you are at the mercy of the policies setup on the mail server you're using to send the emails. No, you can't do anything without one.

This means that if the owner of the mail server says that it will not send or forward an email without a sender address, you have to put one in. If the owner says that the email address MUST match the account that is sending the email, you MUST put your email address in the sender field.

Where I work, it's impossible to send and email without the sender address filled in. It doesn't have to be a valid account. It just has to be filled in.

Now that you've gotten your email onto the server that is sending your mail, you have no defeated those problems. Some servers will not even deliver an email if the sender is not filled in. So leaving the field blank may not work for all of your recipients.

The best method to do what you want is to just create an email address (it usually doesn't even have to exist!) that says "noreply@yourdomain.com" or something similar. If the user replies to the email, that's their problem, not yours. Their email will not be deliverable if the email account doesn't exist. At worst, it'll sit in the inbox of an account that nobody monitors and eventually be deleted by the server.


这篇关于如何发送接收者无法回复的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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