{"id":22640937,"url":"https://github.com/aliencube/sql-mailer","last_synced_at":"2025-03-29T05:26:43.605Z","repository":{"id":23978220,"uuid":"27361123","full_name":"aliencube/SQL-Mailer","owner":"aliencube","description":"This enables SQL Server to send emails through CLR assembly.","archived":false,"fork":false,"pushed_at":"2014-12-01T05:17:36.000Z","size":168,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-03T15:55:22.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aliencube.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-01T03:37:31.000Z","updated_at":"2019-11-06T14:07:10.000Z","dependencies_parsed_at":"2022-08-22T08:40:47.702Z","dependency_job_id":null,"html_url":"https://github.com/aliencube/SQL-Mailer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliencube%2FSQL-Mailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliencube%2FSQL-Mailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliencube%2FSQL-Mailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliencube%2FSQL-Mailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliencube","download_url":"https://codeload.github.com/aliencube/SQL-Mailer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246143533,"owners_count":20730282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-09T04:15:04.442Z","updated_at":"2025-03-29T05:26:43.579Z","avatar_url":"https://github.com/aliencube.png","language":"C#","readme":"# SQL Mailer #\n\n**SQL Mailer** enables SQL Server to send emails through CLR assembly.\n\n\n## Getting Started ##\n\nBefore installing **SQL Mailer** as a CLR assembly, it's worth reading this article, [Send Email from SQL Server Express Using a CLR Stored Procedure](http://www.mssqltips.com/sqlservertip/1795/send-email-from-sql-server-express-using-a-clr-stored-procedure/).\n\nOnce you get confident with this, run the following script.\n\n```sql\n-- Assumes that the CLR assembly is located at 'C:\\Temp\\Aliencube.SqlMailer.Clr'.\nCREATE ASSEMBLY [SqlMailer]\n    FROM 'C:\\Temp\\Aliencube.SqlMailer.Clr\\Aliencube.SqlMailer.Clr.dll'   \n    WITH PERMISSION_SET = EXTERNAL_ACCESS   \nGO\n\nCREATE PROCEDURE [dbo].[usp_SendMail]\n    @applicationName    AS NVARCHAR(256),\n    @body               AS NVARCHAR(MAX)\nAS \nEXTERNAL NAME [SqlMailer].[Aliencube.SqlMailer.Clr.SqlMailer].[SendMail]\nGO\n```\n\nIf you see an error related to `System.Net.Mail`, the following script should be run to allow it.\n\n```sql\n-- Assumes that the database to create the CLR assembly is 'MyDatabase'.\nUSE [master]\nGO\n\nALTER DATABASE [MyDatabase]\n    SET TRUSTWORHTY ON\n    WITH ROLLBACK IMMEDIATE\nGO\n```\n\nIt might not be possible, unless your account has a system administrator privilege. If this is the case, the following script might help.\n\n```sql\n-- Assumes that the database owner is 'aliencube'.\nEXEC sp_changedbowner 'aliencube'\n```\n\nThen create the stored procedure again. Once the stored procedure is created, try the following script for test.\n\n```sql\n-- To success sending an email.\nEXEC usp_SendMail 'Application Name', 'body'\n\n-- To fail sending an email.\nEXEC usp_SendMail 'Application Name', ''\n```\n\n\n## Configuration ##\n\n**SQL Mailer** is highly configurable. With `SqlMail.config`, you can change settings as many times as you can.\n\n```xml\n\u003cconfiguration\u003e\n  \u003csmtp\u003e\n    \u003cenableSsl\u003efalse\u003c/enableSsl\u003e\n    \u003chost\u003elocalhost\u003c/host\u003e\n    \u003cport\u003e25\u003c/port\u003e\n    \u003cdefaultCredentials\u003etrue\u003c/defaultCredentials\u003e\n  \u003c/smtp\u003e\n\n  \u003capplications\u003e\n    \u003capplication\u003e\n      \u003cname\u003eApplication Name\u003c/name\u003e\n      \u003csender\u003efrom@emailserver\u003c/sender\u003e\n      \u003crecipients\u003e\n        \u003crecipient\u003eto@emailserver\u003c/recipient\u003e\n      \u003c/recipients\u003e\n      \u003ccarbonCopies\u003e\n        \u003ccarbonCopy\u003ecc@emailserver\u003c/carbonCopy\u003e\n      \u003c/carbonCopies\u003e\n      \u003cblindCarbonCopies\u003e\n        \u003cblindCarbonCopy\u003ebcc@emailserver\u003c/blindCarbonCopy\u003e\n      \u003c/blindCarbonCopies\u003e\n      \u003csubject\u003eEmail Subject\u003c/subject\u003e\n      \u003cisBodyHtml\u003etrue\u003c/isBodyHtml\u003e\n    \u003c/application\u003e\n  \u003c/applications\u003e\n\u003c/configuration\u003e\n```\n\n\n### `smtp` Section ###\n\n* `enableSsl`: (Optional) Value that specifies whether to enable SSL connection or not. Default value is `false`.\n* `host`: (Optional) SMTP server name. Default value is `localhost`.\n* `port`: (Optional) SMTP server port. Default value is `25`.\n* `defaultCredentials`: (Optional) Value that specifies whether to use default credentials or not. Default value is `true`.\n\n\n### `application` Section ###\n\n* `name`: Name of the application for `SqlMailer` to identify message settings. This is called within a stored procedure.\n* `sender`: Sender's email address.\n* `recipients`: List of recipients' email addresses.\n* `carbonCopies`: (Optional) List of carbon-copied recipients' email addresses.\n* `blindCarbonCopies`: (Optional) List of blind carbon-copied recipients' email addresses.\n* `subject`: Email subject.\n* `isBodyHtml`: (Optional) Value that specifies whether to send emails in HTML format or not. Default value is `true`.\n\n\n## Testing ##\n\nIf necessary, [Papercut](http://papercut.codeplex.com/) might be useful for testing. [Papercut](http://papercut.codeplex.com/) is a standalone application resembling a dummy SMTP/POP server so it doesn't need installation.\n\n\n## Contribution ##\n\nYour contributions are always welcome! All your work should be done in your forked repository. Once you finish your work, please send us a pull request onto our `dev` branch for review.\n\n\n## License ##\n\n**SQL Mailer** is released under [MIT License](http://opensource.org/licenses/MIT)\n\n\u003e The MIT License (MIT)\n\u003e\n\u003e Copyright (c) 2014 [aliencube.org](http://aliencube.org)\n\u003e \n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\u003e \n\u003e The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\u003e \n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliencube%2Fsql-mailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliencube%2Fsql-mailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliencube%2Fsql-mailer/lists"}