DB Mail problem

  • I have configured DB Mail on my server. We have an intranet site, so other colleagues use to send emails through DBMail,

     

    Unfortunately it is not sending for all users,

     

    It is working for most of the users, but doesn't work for few users. All the users got email a/c on our exchange server.

     

    SQL 2005 was installed by my colleague

     

    if the mail is successful,

     

    Date                 19/06/2007 16:27:04

    Log                  Database Mail (Database Mail Log)

     

    Log ID             1160

    Process ID                   3152

    Last Modified               19/06/2007 16:27:04

    Last Modified By                      DLocal\david

     

    Message

    DatabaseMail process is started

     

     

    This is the error message

     

    Date                 20/06/2007 14:53:08

    Log                  Database Mail (Database Mail Log)

     

    Log ID             1183

    Process ID                   4412

    Mail Item ID                 442

    Last Modified               20/06/2007 14:53:08

    Last Modified By                      sa

     

    Message

    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2007-06-20T14:53:08). Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for a subject.).

    )

     

    Problem is Last Modified By for the failed one it is trying to send it from "sa" a/c, for the success one it is sending from "DLocal\david" - david is my colleague name and he is one installed SQL 2005 on this server.

     

    If anyone can help me to solve this issue, I will appreciate your help.

     

  • Check if the other users have permissions to procedure used to send mails. The reason that sa is being called might be they don;t have enough permission to send mails.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • One small correction, send mails through sql server dbmailing system. And you need not have to have a client installed for using database mail in sql 2005.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • Hi Sugesh Kumar,

    Thanks for your reply. All the users have same permissions.

    Actually our setup was two different servers, one is for MS Exchange and other one is for SQL 2005. DB Mail is using email account from MS Exchange. Is anything wrong between Ms Exchange and SQL 2005?

    This is my code works, I'm using asp page to stored all the details in the database table,  say to, cc, body, subject, etc.

    Once it is stored successfully to the table then I'm calling sp_send_dbmail procedure.

    Regards

  • The users need to be a memeber of the DatabaseMailUserRole database role in msdb. 

    IN BOL:

    ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/14cbf88f-d9d1-41a5-994e-532e2973ac9e.htm

    To send Database Mail, you must be a member of the DatabaseMailUserRole database role in the msdb database.

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • Since you say that for one user it works and for the other it doesn't it sure that its a permission issue for the user for whom, it does not work. as said by the previous user give the role mentioned and check if he is able to send mails.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • Hi Thanks for your reply.

    The user means there are two type of users,

    i) On the IT Support page, list of users are from the database table with email id

    ii) Second one is windows active directory (Exchange) users with actual email address..

    The ASP page use the database user account as "web".  When all the users try to send a request, they are using "web" db account. So nothing wrong with that account.

    As I said earlier, it is working for some users, but for the same users sometimes it is not sending.

    I will give you a clear picture of our IT Support setup.


    User: Dropdown list with list of users (picking from database table which contains user's email)

    Cc: Dropdown list with list of users department head to send the copy of the email (Againg from the database table)

    Body: Textarea

    Submit and Reset button


    Procedures:

    1. When someone send a request, he/she has to select their username from the USER list.

    2. If he/she needs to send a copy to their department head then he/she has to select CC

    3. Description of the problem.

    4. When he/she submit the request, I'm storing in a table called "tblHelpDesk" and then calling dbo_send_dbmai stored procedure which picks the values from the table "tblHelpDesk"

    5. ALTER PROCEDURE [dbo].[HelpDeskMail] @var0 varchar(100), @var1 varchar(100), @var2 varchar(200), @var3 varchar(4000), @var4 varchar(200)

    AS

    exec

    msdb.dbo.sp_send_dbmail

    @profile_name

    ="ITSupport",

    @recipients

    =@var0,

    @copy_recipients

    =@var1,

    @subject

    =@var2,

    @body

    =@var3,

    @file_attachments

    =@var4,

    @body_format

    ="HTML"

    ***

    recipients is itsupport@xxxxxx.com

    copy_recipients is the user who send the request

    6. Then dbo_send_dbmail is flushing out to our exchange server, which is another server.

    I suspect there is a problem between exchange server and db server.

    If you see my first post,

    Failed mails are trying to send it through "sa" account

     

    Last Modified By                      sa

     

    If the mail is send successful, then you can see it is send it through "DLocal\david"

    DLocal is our domain and david is the person who installed SQL 2005 on the server.

     

    Last Modified By                      DLocal\david

     

    If you can help me to sort this problem out, I will appreciate your help.

     

    Thanks

  • as a former exchange admin, db mail is just a mini smpt client. you just need to point it to one of your internal smtp server and you are good to go.

  • Hi Veteran,

    It is working for most of the users and most of the time. SMTP and other setup is fine,

     

    I don't know why it is failing.

     

    Thanks for your reply.

  • Hi...we had a similar problem ...look for hidden non-printable characters in the subject...like <carriage return>, <line feed> 

      Users had embedded a carriage return character in the subject..not visible when you are looking at the mail table.  You can easily determine if this is the case by doing a search on the subject in the table as you see it...or searching for subjects that have the ascii  codes in it.  This was what was causing our mail server to reject the email.

    Here is the query used to find the offending subjects that had not been sent:

    select * from sysmail_mailitems where (subject like '%' + char(10) + '%' or subject like '%' + char(13) + '%') and sent_status <> 1

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply