在应用程序内发送群发电子邮件的最佳做法(ASP.NET MVC 2,C#)? [英] Best practise to send mass email within application (ASP.NET MVC 2, C#)?

查看:194
本文介绍了在应用程序内发送群发电子邮件的最佳做法(ASP.NET MVC 2,C#)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网络应用程序中实现群发电子邮件发送功能的最佳方法是什么?两个主要情况:

Whats the best way to implement mass email sending feature within web app? Two major cases:


  1. 根据活动的不同注册用户的电子邮件消息(只需向用户发送简短的提醒,关于新的在他创建的主题中的帖子)

  1. Email messages for separate registered users depending on their activities (just sending short reminders to user for ex about new posts in his created topic)

发送所有注册用户的电子邮件功能,为系统管理员发送一些消息将是非常好的注册用户。当然,向收件人添加所有电子邮件不是我们可以走的方式,因为每个用户的电子邮件地址都是无效的。

"Send email for all registered users" functionality, it will be nice to have feature for system administrator to send some messages for all registered users. Of course adding all emails to recipient isn't the way we can go, because email addresses for each user are anonimous.

正如我所理解的情况nr1没有问题只需创建一些电子邮件通过System.Net.Mail通过创建新的邮件和发送...但是如何情况nr 2 ???

As i understand for case nr1 there is no problem just create some email message via System.Net.Mail by creating new mail message and sending it... but what about case nr 2???

我猜这样的话:

foreach(var emailAddress in emailAddresses) { 

MailMessage mail = new MailMessage();

mail.From = new MailAddress("jondoe@bla.net");

mail.To.Add(emailAddress);

mail.Subject = "test";

mail.Body = "test";

SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

smtp.Send(mail); 
}

不是很好的方式:)所以问题是什么是最好的实现这一点的方式?

isn't the good way :) so the question is what is the best way to achieve this ?

btw我们不可能部署一些电子邮件发送,这应该被集成到Web应用程序。

btw we have no possiblity to deploy some serive for email sending, this should be integrated into web application.

推荐答案

如果你想隐藏谁将会遇到的情况2为什么你不能把收件人放入MailMessage的BCC?

If you want to hide who it's going to in case 2 why can't you put the recipients into the BCC of MailMessage?

我建议的一件事是在您的web.config中定义您的电子邮件设置,如下所示:

One thing I would recommend is to define your email settings in your web.config like below:

<configuration>
  <!-- Add the email settings to the <system.net> element -->
  <system.net>
    <mailSettings>
      <smtp>
        <network 
             host="relayServerHostname" 
             port="portNumber"
             userName="username"
             password="password" />
      </smtp>
    </mailSettings>
  </system.net>

  <system.web>
    ...
  </system.web>
</configuration>

这篇关于在应用程序内发送群发电子邮件的最佳做法(ASP.NET MVC 2,C#)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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