sending email from sql azure

2019-06-24 05:00发布

问题:

Hey all,
just quick question about sql azure. My App is running on windows azure and the database is on sql azure. Everything is working great. However, I would like to send email to a user, as soon as he\she became a member.I don't want to Use

    - third party service
    - send email from the code.

Is there any way to send email by using a trigger and stored procedure? For example: run trigger after each updated for user table and trigger will run stored procedure. Thanks in advance . Matt

回答1:

As far as I know, there is no way to send an email from SQL Azure directly. You will have to use a web, worker or VM role to actually send email. In general, sending email from Azure data centers is tricky because spam filters flag Azure IP addresses as unsafe (see https://alinirimie.sys-con.com/node/1404827). To avoid this problem, you must use a third party SMTP service (we use Amazon SES) or your own SMTP server. If you want to connect to your own SMTP server through a firewall, you can use Windows Azure Connect to establish a secure tunnel from Azure to your local network.



回答2:

I realize you stated that you do not want to use a 3rd party services, but for others that might be reading this and would be open to this. Cotega allows you to send emails directly from SQL Azure.

Full disclosure, I work on Cotega.



回答3:

There is some documentation on hacks you can do here: http://vpolizzi.wordpress.com/2010/09/11/database-mail-on-sql-azure/

However I think using a worker role would be more robust and maintainable.