mysql配置数据库邮件_命令行配置数据库邮件

--下面是具体的配置邮件步骤

--在 sa 系统帐户下运行。

--

--1. 启用 SQL Server 2005 邮件功能。

use master

go

exec sp_configure 'show advanced options',1

go

reconfigure

go

exec sp_configure 'Database mail XPs',1

go

reconfigure

go

--2. 在 SQL Server 2005 中添加邮件帐户(account)

exec msdb..sysmail_add_account_sp

@account_name = 'mail_131_25' -- 邮件帐户名称(SQL Server 使用)

,@email_address = 'dbuser@genius.com.cn' -- 发件人邮件地址

,@display_name = 'dbuser@genius.com.cn' -- 发件人姓名

,@replyto_address = null

,@description = null

,@mailserver_name = 'smtp.genius.lcom.cn' -- 邮件服务器地址

,@mailserver_type = 'SMTP' -- 邮件协议(SQL 2005 只支持 SMTP)

,@port = 25 -- 邮件服务器端口

,@username = 'dbuser@genius.com.cn' -- 用户名

,@password = 'xxxx' -- 密码

,@use_default_credentials = 0

,@enable_ssl = 0

,@account_id = null

--3. 在 SQL Server 2005 中添加 profile

exec msdb..sysmail_add_profile_sp @profile_name = 'dba_profile' -- profile 名称

,@description = 'dba mail profile' -- profile 描述

,@profile_id = null

-- 在 SQL Server 2005 中映射 account 和 profile

exec msdb..sysmail_add_profileaccount_sp @profile_name = 'dba_profile' -- profile 名称

,@account_name = 'mail_131_25' -- account 名称

,@sequence_number = 1 -- account 在 profile 中顺序

--5. 利用 SQL Server 2005 Database Mail 功能发送邮件。

exec msdb..sp_send_dbmail @profile_name = 'mail_131_25' -- profile 名称

,@recipients = 'yu.baolong@genius.com.cn' -- 收件人邮箱

,@subject = 'SQL Server 2005 Mail 测试' -- 邮件标题

,@body = 'Hello Mail!测试' -- 邮件内容

,@body_format = 'TEXT' -- 邮件格式

--6. 查看邮件发送情况:

use msdb

go

select * from sysmail_allitems

select * from sysmail_mailitems

select * from sysmail_event_log order by log_id desc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值