Setting up Database mail using gmail account

  • Achtang

    SSCommitted

    Points: 1602

    Hi,,

    any one any idea about this?

    I am trying to set up Databases mail on my laptop and I have a gmail account. you know how to set that up? What is the server name for gmail account?

    I am guessing either smtp.gmail.com or pop.gmail.com try to send test mail but does not work :(. please help me....

    I get this error:

    Message

    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 5 (2009-04-05T18:20:09). Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for an e-mail address.).

    )

  • KenSimmons

    SSCertifiable

    Points: 7822

    I have never set up Database Mail using Gmail, but this link may help.

    http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

  • Achtang

    SSCommitted

    Points: 1602

    Thanks Ken,

    still no joy

    I dnt have company mail adress. I am at learning stages trying to get into sql server. now, since i dont have company email how can i set it up my own mail account on my computer? I know this is out of sql but sorry if u want i can start a new topic.

    how can i set it up my own mail on my computer so that i can test databases mail using that? any help pleae?....

    thanks,

  • Boolean_z

    SSCommitted

    Points: 1807

    I tried gmail - never worked.

    then i tried other free POP/SMTP server hotpop.com , the smtp address is smtp.hotpop.com , port number 25

    although it also failed for me, but you can try it.

  • Mark Sumner

    SSCommitted

    Points: 1851

    Your SQL server needs an SMTP server to relay your message to the destination email address.

    http://mail.google.com/support/bin/answer.py?hl=en&answer=13287 tells you how to configure a client to access your gmail account to read your email.

    What you are trying to achieve is to send an email from your SQL server to your gmail account. Most SMTP servers will deny relays from unknown systems. You can blame spammers the world over for that!

    You don't need an email account with your company to make Database Mail work, but you do need an SMTP relay server to accept connections from your SQL box.

    Is there a mail system at your company? If so, have a polite word with the email administrator and ask him if he would mind adding the IP address of your SQL server to be allowed to use the SMTP relay. If your company has its own mail system, they will have one. If they all use gmail, like you, you may be stuck!

  • maechismo_8514

    SSCoach

    Points: 17510

    True, I tried to set it up too but never had success :~(.

    I think gmail offers you some package for small organizations with some little amount to pay. that might help:-P

  • tcnolan

    SSCrazy

    Points: 2097

    Try this...

    Use smtp.gmail.com for the server

    Change port to 465

    Require secure connections checked

    Basic authentication with your gmail username and password (make sure you use the full email address for username with @gmail.com at the end)

    If that doesn't work, you could try installing IIS locally on your machine and run an SMTP server. Allow relay only for localhost and you should be able to use that for the server in database mail without an issue. Just make sure there isn't a firewall blocking the traffic outbound. It's an easy thing to try and it will probably work.

  • Mark Sumner

    SSCommitted

    Points: 1851

    tnolan (4/6/2009)


    Try this...

    Use smtp.gmail.com for the server

    smtp.gmail.com is the outbound from gmail smtp server. It will refuse your relay request.

    If that doesn't work, you could try installing IIS locally on your machine and run an SMTP server. Allow relay only for localhost and you should be able to use that for the server in database mail without an issue. Just make sure there isn't a firewall blocking the traffic outbound. It's an easy thing to try and it will probably work.

    This might work for an email address in the same domain, but to send to external domains iis smtp needs a smarthost (smtp relay) to relay email. I think it'll present the same problem as database mail.

  • tcnolan

    SSCrazy

    Points: 2097

    Mark Sumner (4/6/2009)


    tnolan (4/6/2009)


    Try this...

    Use smtp.gmail.com for the server

    smtp.gmail.com is the outbound from gmail smtp server. It will refuse your relay request.

    If that doesn't work, you could try installing IIS locally on your machine and run an SMTP server. Allow relay only for localhost and you should be able to use that for the server in database mail without an issue. Just make sure there isn't a firewall blocking the traffic outbound. It's an easy thing to try and it will probably work.

    This might work for an email address in the same domain, but to send to external domains iis smtp needs a smarthost (smtp relay) to relay email. I think it'll present the same problem as database mail.

    smtp.gmail.com actually does work. I just tested this myself. The only difference is that I had to change the port to 587. see attachment. sent to two non-gmail accounts and a gmail account as a test.

  • sayfrend

    SSCommitted

    Points: 1733

    I have Setup Database Mail through gmail. It works absolutely fine with no issue.

    Like Ajay Said, we have to use port 587. In many websites this port is given wrong.

    I have explained all the steps to configure DatabaseMail through Gmail.

    @ Narayan,

    By default we will use port 25 to configure database mail, which is usually blocked by windows firewall for security reason,

    try the following.

    1. Disable firewall and test if databasemail sends email.

    2. Make an exception in the windows firewall.

    Or this also happens when you use wrong port numbers,

    Just as an example use these values when setting up a database mail feature: You need to have a gmail account, which can be created free if you go to gmail.com, you can send email using gmail service free of cost 🙂 So you can try this example and it works perfect.

    In database mail, first create profile, and when you create an account, use these values.

    Give Account name: SQL Server Alerts System

    Description: XYZ

    Outgoing mail Server ( SMTP)

    email id: youremailid#gmail.com ( should have gmail.com)

    Display Name: SQL Server

    Reply email: can leave blank

    Server name: smtp.gmail.com ( this is really important)

    port no: 587 ( on many website this is given as 465 which is wrong, use 587 )

    Check : This server requires a secure connection

    Check Basic Authentication

    username: youremailid@gmail.com ( should have gmail.com)

    password: ( top secret , dont display ) … 😉

    confirm password: confirm your password

    click next and also you need to make it default public profile.

    After you do this, you also have to change SQL Server Agent properties, in Properties click alerts system and then select database mail.

    MOST IMRORTANT when you make changes, to SQL SERVER AGENT properties, restart only SQL SERVER AGENT.

    right click SQL Server Agent and click restart, and then test your database mail.

    to test, right click database mail and click send test mail… VERY IMPORTANT ( Select right profile/account from drop down list), put any email id and click send test email. click ok.

    Right click database mail, select view database mail logs keep refreshing … to see if any error message had occured. mean while look in your inbox if you recieved your email.

    In few days I will take screen shots on how to configure database mail, taking a live example.

    All with GUI’s no scripts 🙂

    Hope this helps.

    Imran.

    Reference:

    ~ IM

  • Boolean_z

    SSCommitted

    Points: 1807

    That's great ! how u got that port number is 587, not 465 as provided by google.

  • Boolean_z

    SSCommitted

    Points: 1807

    It still fails for me

    Message

    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2009-04-07T08:45:10). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at ).

    )

  • tcnolan

    SSCrazy

    Points: 2097

    Boolean_z (4/6/2009)


    It still fails for me

    Message

    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2009-04-07T08:45:10). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at ).

    )

    Double check your password... if you made a setting change and saved the profile, go back and re-enter the password and save the profile again. If that doesnt work give port 465 a shot again, but make sure to re-enter your password when you make the change again, for some reason SSMS only prints two or three stars in the password box, and seemingly recalculates a hash based on some hidden text in there.

    I had the same thing happen to me. I have a 12 or so character password that was redisplayed as only two stars when I went back in to change settings and re-saving made auth fail. Went in and entered my password again and I had success.

  • Lonely Rogue

    SSCrazy

    Points: 2578

    Hello @sayfrend,

    I used those instructions and configured Gmail...however, when i tried sending a test mail,it failed.

    Below is the DBMail log entry:

    Message:

    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2009-04-07T12:23:31). Exception Message: Could not connect to mail server. (No such host is known).

    )

    I have also created an exception in my firewall: TCP 587 and restarted my sql server..still no use.

    Can you or some one please let me know about this error?

    Thanks,

    [font="Comic Sans MS"]Vampire[/font]

    --In 'thoughts'...
    Lonely Rogue

  • tcnolan

    SSCrazy

    Points: 2097

    That error is basically saying that the database server cannot resolve the host smtp.gmail.com [edit]or it simply can't reach the server if it is able to resolve an IP[/edit].

    Did you double check to make sure there are no typos in the server name?

    Check if you can ping that smtp.gmail.com from the database server.

    If you cannot resolve an IP than you are having some kind of DNS issue.

    You could add a hosts entry to your machine if you are unable to resolve DNS issue, but there are no guarantees that the IP will not change.

Viewing 15 posts - 1 through 15 (of 50 total)

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