配置邮件服务器(SMTP简单步骤)

news/2025/2/26 7:48:57

步骤:

 

1. 安装SMTP

 

2. 配置SMTP, 配置你要中转的邮件所用的邮件服务器,例如你的SMTP要中转Gmail的邮件,那么你就需要设置SMTP.  当然你可以配置自己POP3服务器,建立自己的域名,建立自己的邮件。

 

    more info, see here:

 

http://fmuntean.wordpress.com/2008/10/26/how-to-configure-iis-smtp-server-to-forward-emails-using-a-gmail-account/

 

3. Enable Database Mail功能(SQL20008 or 2005)/Enable SQL Agent service via ruuning Services.MSC in cmd

 

4. 配置database Mail account and profile

 

more info:

http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/

or

http://www.db-staff.com/index.php/microsoft-sql-server/90-configure-database-mail

 

5. 在step4中,配置好"From" email address, 和 "Reply" email adress

 

6. 执行下列脚本(或者右键点击Database Mail to sent a test):

 

EXEC msdb.dbo.sp_send_dbmail
  @profile_name = 'JohnTest', --你在step4中建立的profile的名字
  @recipients = 'MMM@hotmail.com', --你要给谁发邮件
  @subject = 'aaa',
  @body = 'just a test',
  @body_format = 'HTML';

 

Example:

假设有一个需求,一个用户在网站注册了用户信息后,收到网站注册成功的邮件提示。

 

数据库层:

建立表user; User(UserID, Name, Email, age, Sex,....)

建立表Emailqueue(EmailqueueID, UserID,To, Subject, body.....)

建立一个trigger on the talbe Emailqueue. Trigger tr_SendNotificationMail 触发的操作为inseration. Trigger中将包含类似的脚本

.....

.....

declare @To string

declare @S string

declare @B string

.....

.....

EXEC msdb.dbo.sp_send_dbmail
  @profile_name = 'JohnTest', --你在step4中建立的profile的名字
  @recipients = @To --你要给谁发邮件
  @subject =@S,

  @body = @B,

  @body_format = 'HTML';

 

建立存储过程sp_insertUser; 这个存储过程会向表Usere中插入数据,并且调用sp_insertEmail.

建立存储过程sp_insertEmail; 这个存储过程将向Emailqueue中插入数据,并被Sp_InsertUser调用。

 

流程:

用户A注册-->程序调用sp_insertuser-->用户A被插入User表中;sp_InsertEmail被调用-->Email信息被插入Emailqueue表中

--->Trigger tr_SendNotificationMail被触发--->邮件发出

 

 

 


  


http://www.niftyadmin.cn/n/1221444.html

相关文章

js效果点击显示,点击隐藏。

<table> <tr> <td height"28" align"right" class"tleft">回收旧料&#xff1a; </td> <td colspan"2" class"tright"> <input name"choose" type"checkbox" id&quo…

SET QUOTED_IDENTIFIER ON

SET QUOTED_IDENTIFIER ON SQL SERVER的联机丛书的解释&#xff1a; “当 SET QUOTED_IDENTIFIER 为 ON 时&#xff0c;标识符可以由双引号分隔&#xff0c;而文字必须由单引号分隔。当 SET QUOTED_IDENTIFIER 为 OFF 时&#xff0c;标识符不可加引号&#xff0c;且必须遵守所…

javaweb学习总结(十一)——使用Cookie进行会话管理

一、会话的概念 会话可简单理解为&#xff1a;用户开一个浏览器&#xff0c;点击多个超链接&#xff0c;访问服务器多个web资源&#xff0c;然后关闭浏览器&#xff0c;整个过程称之为一个会话。   有状态会话&#xff1a;一个同学来过教室&#xff0c;下次再来教室&#xff…

SQL Code Coverage

See the email from Hotmail and Gmail.........

Net平台下的Mock工具---Rhino Mocks

Net平台下的Mock工具---Rhino Mocks Mock对象是一种方便写单元测试的辅助工具。当被测试的某个类需要依赖其它类的时候&#xff0c;采用Mock对象可以模拟出依赖对象的类型和一些特定的调用&#xff0c;从而隔离了被测试单元之间的互相影响。比如你的某个业务逻辑组件需要调用数…

JavaWeb学习总结(十二)——Session

一、Session简单介绍 在WEB开发中&#xff0c;服务器可以为每个用户浏览器创建一个会话对象&#xff08;session对象&#xff09;&#xff0c;注意&#xff1a;一个浏览器独占一个session对象(默认情况下)。因此&#xff0c;在需要保存用户数据时&#xff0c;服务器程序可以把用…

BDD: 使用 SpecFlow 和 WatiN 进行行为驱动开发

MSDN 杂志 > 主页 > 所有期刊 > 2010 > MSDN 杂志 十二月 2010 > MSDN 杂志&#xff1a;BDD 入门 - 使用 SpecFlow 和 WatiN 进行行为驱动开发link: http://dengbq.blog.163.com/blog/static/4634654620110283470713/BDD 入门 使用 SpecFlow 和 WatiN 进行行为…

40而不惑

现在不到40的人&#xff0c;都是不惑。这个社会让人成长&#xff0c;成熟&#xff0c;然后&#xff0c;没有然后了。。。转载于:https://blog.51cto.com/zhanghebei2/1219379