Description:
XPSMTP provides a SMTP based SQL Mail solution for sending MIME based email over SMTP, implemented as an Extended Stored Procedure.
It does not require any software to be installed, just a SMTP email server that can handle the outgoing mail request. XPSMTP is using TCP/IP sockets to communicate to port 25. XPSMTP does not spawn additional threads, the xp_smtp_sendmail request is handled on the same thread as it is being called on by SQL Server. Each call to xp_smtp_sendmail establishes a connection to the SMTP server and disconnects when done sending the email. The connection is created using asynchronous communication and aborts based on a timeout value (@timeout which by default is 10000 milliseconds, so 10 seconds).
Usage:
XPSMTP only supports named parameters, since the number possible of parameters is already big and will get extended over time and since most of these parameters are optional, XPSMTP does not support ordinal parameters, mainly to reduce complexity, ambiguity and the change on mistakes.
Installation:
To install XPSMTP follow these instructions:
1. For SQL Server 2000, download XPSMTP80.ZIP and unzip the files. Files be located on end this contribution
2. Copy xpsmtpXX.dll into the SQL Server BINN directory. For SQL Server 7.0 copy XPSMTP70.DLL, for SQL Server 2000 copy XPSMTP80.DLL
For SQL Server 7.0 the default installation location is "C:\MSSQL7\BINN"
For SQL Server 2000 the default location is "C:\Program Files\Microsoft SQL Server\MSSQL\Binn"
3. Register the extended stored procedure using OSQL or SQL Query Analyzer by executing:
— SQL Server 7.0 install
exec sp_addextendedproc ‘xp_smtp_sendmail’, ‘xpsmtp70.dll’
— SQL Server 2000 install
exec sp_addextendedproc ‘xp_smtp_sendmail’, ‘xpsmtp80.dll’
4. Grant rights to the correct set of users using OSQL or SQL Query Analyzer by executing:
grant execute on xp_smtp_sendmail to public
By default only the member of the sysadmin role have execution rights on the XP after it is being registered
Parameters:
This is the complete list off parameters used by xp_smtp_sendmail. The parameter names used are case-insensitive. When a parameter is marked as mandatory (only @FROM and @TO) this means you have to provide a valid value, all other parameters are optional. Either because default values are provides, either because they are really optional in nature.
Tries to connect to @server (using @timeout), if successfuly connected @rc = 0 otherwise @rc = 1. This can be used to validate connections to the SMTP server
Return codes:
The procedure returns only two return codes, 0 (zero) indicating successful execution, 1 indicating failure always accompanied with an error message.
This is how to retrieve the return code:
declare @rc int
exec @rc = master.dbo.xp_smtp_sendmail …
select @rc
Uninstall:
To remove XPSMTP from a system follow these instructions:
1. Force the DLL out of memory, using OSQL or SQL Query Analyzer by executing:
dbcc xpsmtp70(free) — for SQL Server 7.0
dbcc xpsmtp80(free) — for SQL Server 2000
2. Unregistered the XP from the system, using OSQL or SQL Query Analyzer by executing:
exec sp_dropextendedproc ‘xp_smtp_sendmail’
3. Delete the XPSMTP70.DLL or XPSMTP80.DLL from the SQL Server BINN directory
Recent Comments