Lloyd Banks
Lloyd Banks

Reputation: 36648

Can't Send SQL Server Database Mail Through PHP

I have a SQL Server procedure that does inserts and sends an e-mail to a recipient. The procedure works as expected inside of SSMS. When I call the procedure using the mssql wrapper in PHP

mssql_query("EXEC myprocedure 'mypara1' 'mypara2'");

the inserts are performed, but the database mail function is not performed. I stripped out the insert from the original procedure and left the database mail function in the procedure by itself and no e-mail was sent.

Is there a reason why database mail is disabled if you use the 'mssql_query' function? Is there another way for me to call my procedure so that database mail functions as expected?

Upvotes: 0

Views: 235

Answers (1)

Marc B
Marc B

Reputation: 360672

Are you using the same login when you're testing this? Whatever user php is logging in as may not have the same rights as whatever you logged in to SSMS as.

Upvotes: 1

Related Questions