C# 更改电子邮件“来自”用户提供的地址

发布于 2024-08-31 02:09:14 字数 345 浏览 3 评论 0原文

我们有一个应用程序,允许用户从我们的系统发送电子邮件。它允许用户指定他们的电子邮件地址,并为他们提供几个标准模板以用作电子邮件的起点。

当我们发送电子邮件时,我们使用他们提供的地址作为“回复”,但电子邮件的“发件人”地址(自然)看起来像我们的系统(来自“[电子邮件受保护]')。

有没有办法改变这一点,而不会陷入垃圾邮件过滤器或自动阻止的困境?我们不想让收件人混淆他们收到的电子邮件的实际作者是谁。

We have an app that allows users to send e-mails from our system. It allows the user to specify their e-mail address, and gives them several standard templates to use as a starting point for their e-mail.

When we send the e-mails, we use the address they provided as the 'reply-to', but the 'from' address of the e-mail (naturally) looks like our system (from '[email protected]').

Is there a way to change this without getting tangled up in spam filters or automatic blocking? We'd prefer not to confuse the recipient as to who actually composed the e-mail they've received.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

柳若烟 2024-09-07 02:09:14

我将向您推荐 Jeff Atwood 的关于以编程方式发送电子邮件的编码恐怖文章。它详细描述了您应该采取的步骤来防止您的电子邮件被垃圾邮件过滤器捕获等...

杰夫·阿特伍德的编码恐怖:所以你想发送一些电子邮件(通过代码)

I'll refer you to Jeff Atwood's Coding Horror article about sending e-mail programattically. It describes in lengths the steps you should take to prevent your e-mail from being caught in spam filters, etc...

Jeff Atwood's Coding Horror: So You'd Like to Send Some Email (Through Code)

浅语花开 2024-09-07 02:09:14

我使用这段代码:

public static bool sendEmail(string fromName, string fromEmail, string body, string subject, string toEmail) {

    String strReplyTo = fromEmail.Trim();
    String strTo = toEmail;
    String msgBodyTop = "Email from: " + @fromName + "(" + @fromEmail + ")\n"
            + "" + " " + DateTime.Now.ToLongTimeString()
            + " FROM " + HttpContext.Current.Request.Url.ToString + " : \n\n"
            + "---\n";

    MailMessage theMail = new MailMessage(fromEmail, strTo, subject, msgBodyTop + body);

    theMail.From = new MailAddress(strReplyTo, fromName);

    SmtpClient theClient = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString());

    theClient.Send(theMail);

    return true;
}

它似乎对我有用......

I use this code:

public static bool sendEmail(string fromName, string fromEmail, string body, string subject, string toEmail) {

    String strReplyTo = fromEmail.Trim();
    String strTo = toEmail;
    String msgBodyTop = "Email from: " + @fromName + "(" + @fromEmail + ")\n"
            + "" + " " + DateTime.Now.ToLongTimeString()
            + " FROM " + HttpContext.Current.Request.Url.ToString + " : \n\n"
            + "---\n";

    MailMessage theMail = new MailMessage(fromEmail, strTo, subject, msgBodyTop + body);

    theMail.From = new MailAddress(strReplyTo, fromName);

    SmtpClient theClient = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString());

    theClient.Send(theMail);

    return true;
}

It seems to work for me...

强辩 2024-09-07 02:09:14

在与我们的运营人员讨论并尝试 Atomiton 的方法之后,我发现这对我们来说实际上是不可能的。

After discussing with our ops people and trying Atomiton's method, I've found that this is not actually possible for us.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文