Categories > TinyButStrong general >

Update to Sending Email with TBS/TBSsql

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Don Bledsoe
Date: 2007-06-11
Time: 13:02

Update to Sending Email with TBS/TBSsql

In "Your tips & tricks" section (http://tinybutstrong.com/forum.php?msg_id=3574#), Aureo asked about sending email with TBS back in 2005, but I wanted to update it to work with TBSsql. The code below produces no errors, but doesn't work and I can't see what I'm doing wrong:

// Open the MySQL query
$qid = $Db->GetRows('SELECT * FROM domains WHERE (expiresdays < 31)');

//$Db->MergeBlock('blk','tbssql','SELECT * FROM domains WHERE (expiresdays < 31)');

// Load the template, and save the source
$TBS->LoadTemplate('tpl/emailnotice.tpl.html');
$emailBody = $TBS->Source;

// Prepare TBS to not exit at the end of the Show method
$TBS->Render =  TBS_NOTHING;

// Loop for all domains to send email notice
while ($domains = @mysql_fetch_assoc($qid)) {

// Retrieve initial source
$TBS->Source = $emailBody;

// Merge invoice data
$TBS->MergeBlock('blk',$domains);

// Merge automatic fields
$TBS->Show();

// Send the email
$To  = $qid['email'] . ", dbledsoe@forefrontinternet.com";
$From = "CustomerCare@forefrontinternet.com";
$Subj = 'Your Domain Registration is Expiring Soon';
mail($To,$Subj,$TBS->Source,$From);
}

$Db->Close();
By: Skrol29
Date: 2007-06-11
Time: 14:27

Re: Update to Sending Email with TBS/TBSsql

Hi,

What do you mean by "doesn't work" ?
Whats happens, and what is expected ?
By: Don Bledsoe
Date: 2007-06-11
Time: 23:34

Re: Update to Sending Email with TBS/TBSsql

Well, no email is being generated, as nearly as I can tell.

Is there a way to see/log debug information as the script is running? I tried some echo statements, but nothing was displayed. Echos  with the class executes, but not in my script.

A debug dump would be very handy, like ...
$TBS->Debug();
$Db->Debug();
... to dump the current status of everything and list the content of all variables whenever the statement is encountered. This is a very nice feature in ezSQL for n@@b wannabe-programmers like me.
By: Skrol29
Date: 2007-06-11
Time: 23:46

Re: Update to Sending Email with TBS/TBSsql

Hi,

There can be many reasons to have the function email() not working.
To check if it comes from TBS, just display the contents of $TBS->Source to see if you have what is expected.

If all is ok for the TBS job, then I suggest you to use the class PhpMailer.
Search for "class.phpmailer.php" on the web.