I have some code that is loaded as a custom mail sending handler. The idea is to get around the "web server can't send e-mail" rule of SourceForge.net, for user registrations. The mail sending handler gets called with some data for e-mails (I test this with the contact page), but the db_query() fails. When I attempt to write the query to a readable file, the mysql error string is empty.
How do I debug this? (Code follows)
<?php
/*
CREATE TABLE 'outgoing_mail' (
'mailkey' VARCHAR( 100 ) NOT NULL ,
'mailto' VARCHAR( 100 ) NOT NULL ,
'subject' VARCHAR( 100 ) NOT NULL ,
'body' TEXT NOT NULL ,
'from' VARCHAR( 100 ) NOT NULL ,
'headers' TEXT NOT NULL ,
'inserttime' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
'sendtime' TIMESTAMP NULL ,
'id' INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
INDEX ( 'sendtime' )
) ENGINE = MYISAM ;
*/
function drupal_mail_wrapper($mailkey, $to, $subject, $body, $from, $headers) {
db_set_active();
if (!db_query("insert into outgoing_mail values('%s', '%s', '%s', '%s', '%s', '%s')",
$mailkey, $to, $subject, $body, $from, $headers)) {
$f = fopen("/tmp/persistent/kwxport-files/error-$mailkey", "wb");
fwrite($f, "Error to: $to\n".mysql_error($active_db)."\n");
fclose($f);
}
return true;
}
function drupal_send_mail() {
include_once "./sites/default/settings.php";