I want to use Database mail for my application and this means I need to pass parameters to the stored procedure sp_send_dbmail
I have the following code just for testing purposes. I however want to know how to pass Parameters to a stored procedure using ssql server 2008 and php.
FYI I am using sqlsrv driver from Microsoft
<?php require_once ('../Connection/connmail.php')?>
<?php
$sql = "{CALL sp_send_dbmail[[@profile_name='gmailsmtp']]}";//my stored procedure
$stmt = sqlsrv_query($conn,$sql)or die(print_r(sqlsrv_errors(),true));
?>
The above code produces the error
Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 102 [code] => 102 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '{'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '{'. ) [1] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 105 [code] => 105 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Unclosed quotation mark after the character string '[@profile_name='gmailsmtp']}'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Unclosed quotation mark after the character string '[@profile_name='gmailsmtp']}'. ) )
Any help will be appreciated
I saw this was unanswered for a while so here is the solution. Make your user a
databasemailuserrolein the msdb system database