Pouyan


Hi every body


I want to send a simple mail using DATABASE MAIL feature in SQL SERVER 2005.

I've defined a public profile.
I've enabled Database Mail stored procedures through the Surface Area Configuration .

but   I can't send a mail with sp_send_dbmail stored procedure in 'msdb' database .


when I execute sp_send_dbmail in the Managment Studio  the message is
"Mail queued"  but the mail is not sent.

Could it be related to Service Broker Because  the Surface Area Configuration indicates:'this inctance does not have a Service Broker endpoint'.If so, how should I make an endpoint

here is the log file after executing sp_send_dbmail:


1)  "DatabaseMail process is started"

2)   "The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2007-03-08T00:49:29). Exception Message: Could not connect to mail server. (No connection could be made because the target machine actively refused it)."

 The DatabaseMail90.exe is triggred ,so the mail is transfered to the mail queue but  DatabaseMail90.exe couldn't give the mail to SMTP server.The promlem is what should I do to make DatabaseMail90.exe able to connect to  the server



please help me.

POUYAN




Re: Problem with sending mail via Database Mail

tosc


Hi POUYAN,

you must have enabled the Service Broker in the msdb database.

BOL: How to: Activate Service Broker Message Delivery in Databases (Transact-SQL)

To see if the message was sent successfully, you can run a query on the sysmail_allitems system view.

SELECT * FROM sysmail_allitems
 






Re: Problem with sending mail via Database Mail

Pouyan

Hi

By default service broker is enabled in each database except 'master' & 'tempdb'

any way again I enabled service broker.

where as DatabaseMail90.exe is triggerd whene I execute sp_send_dbmail,the mail should be given to the queue.but when I execute

sysmail_help_queue_sp to see the queue the 'length' column is 0 which says there is no mail in the queue.I'm confused.

More over I think another problem is that DatabaseMail90.exe can not communicate with the machine(server) .

do u know how I can check communication settings between SQL SERVER and the server to see what's going on

thanks.

POUYAN.






Re: Problem with sending mail via Database Mail

tosc

Hi POUYAN,

plz check:

SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb' ;

A value of 0 indicates that Service Broker message delivery is not activated in the msdb database

EXEC msdb.sys.sp_helprolemember 'DatabaseMailUserRole': --- check members of the DatabaseMailUserRole

EXEC msdb.dbo.sysmail_help_principalprofile_sp

EXECUTE dbo.sysmail_help_status_sp ; --- check status of Database Mail

EXECUTE dbo.sysmail_start_sp: ---start Database Mail in a mail host database

EXEC msdb.dbo.sysmail_help_queue_sp @queue_type = 'mail'






Re: Problem with sending mail via Database Mail

Remus Rusanu

Pouyan wrote:

Could it be related to Service Broker Because the Surface Area Configuration indicates:'this inctance does not have a Service Broker endpoint'.If so, how should I make an endpoint

You do not need an endpoint for database mail.

Pouyan wrote:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2007-03-08T00:49:29). Exception Message: Could not connect to mail server. (No connection could be made because the target machine actively refused it).

The problem has nothing to do with Service Broker. Your mailer process gets the mail to send and attempt to deliver, but ot cannot. The problems seems to be with yoyr @mailserver_name or @port parameters passed to sysmail_add_account_sp.

HTH,
~ Remus






Re: Problem with sending mail via Database Mail

Pouyan

Hi

I 've just installed SMTP services from the "add windows component"

(I hadn't done !!!!)

but this time I'm facing a new error type:

"

Message
The mail could not be sent to the recipients because of the mail server failure.
(Sending Mail using Account 1 (2007-03-14T03:55:26).
Exception Message: Cannot send mails to mail server
. (Mailbox unavailable. The server response was: 5.7.1 Unable to relay for pooyan_pdm@yahoo.com).
)
"

and when I execute sysmail_help_queue_sp this would be the resuls:

queue_type length state last_empty_rowset_time last_activated_time
---------- ----------- -------------------------------------------
mail 0 RECEIVES_OCCURRING 2007-03-14 12:44:29.713 2007-03-14 12:38:48.463
status 0 INACTIVE 2007-03-14 12:44:29.763 2007-03-14 12:44:29.713

------------------------------------------

*database mail is enabled

*service broker is ebabed(is_broker_enabled=1 for msdb in the sys.databases)

------------------

you said this may be because off port or server name:

in the account I use to send the mail I have set these vause:

server name:pouyan(computer name in the system properties)

port =25

should they be any thing else

thanks

pouyan.





Re: Problem with sending mail via Database Mail

Pouyan

Hi

I checked every thing just as u said every thinh was ok

here is the result of executin sysmail_help_queue_sp:

queue_type length state last_empty_rowset_time last_activated_time
---------- ----------- -------------------------------------------
mail 0 RECEIVES_OCCURRING 2007-03-14 12:44:29.713 2007-03-14 12:38:48.463
status 0 INACTIVE 2007-03-14 12:44:29.763 2007-03-14 12:44:29.713

-----------------------------------------

I just today installed SMTP services!!!!

and the type of error changed to this form:

"

Message
The mail could not be sent to the recipients because of the mail server failure.
(Sending Mail using Account 1 (2007-03-14T03:55:26).
Exception Message: Cannot send mails to mail server
. (Mailbox unavailable. The server response was: 5.7.1 Unable to relay for pooyan_pdm@yahoo.com).
)

"

And there is another thing to tell : starting the database mail external(databasemail90.exe) is not mentioned in sysmail_event_log or Windows Application event log.

but I can see databasemail90.exe running in the prosses tab of the Task Manager.

I'm extremly confused.





Re: Problem with sending mail via Database Mail

Remus Rusanu

You need not only install SMTP service, but you also need to configure it properly. See http://support.microsoft.com/kb/304897 for how to test your SMTP relay.




Re: Problem with sending mail via Database Mail

Pouyan

Every thing is ok

thanks





Re: Problem with sending mail via Database Mail

Manish Gupta

Pouyan,

This may also be happeneing because of any antivirus installed on your machine. BCoz Antivirus softwares ususally block the ports. For example, Macfee blocks the port no 25 which is used by SQL server to send mails.





Re: Problem with sending mail via Database Mail

Anonymous

I have to set up database mail to send emails using .

I am also getting the same error. I tested for SMTP relay service also.

am still getting this error :

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2007-04-09T15:24:10). Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc@abc.com

can u please let know where I can find the errors.






Re: Problem with sending mail via Database Mail

Bozo Biskupic

Hi,

can you pls. explain to me in short how did you solve this problem

I'm getting the same error message....

Thnx a lot in advance.

BR,

Bozo





Re: Problem with sending mail via Database Mail

Dml256

This problem was caused for ME because of Anti-Virus.

AV blocks services from sending on TCP-25 (like an email worm). Adjust the AV software accordingly. Add DATABASEMAIL90.EXE to the list of innocent programs in your AV.