Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Fri Apr 19, 2024 7:25 pm
VoIP Billing solution


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: i configure the email reminder, but don´t work
PostPosted: Sun Jun 22, 2008 1:00 pm 
Offline

Joined: Fri Jan 18, 2008 1:33 am
Posts: 4
Location: buenos aires

i read in another page of this forun but i don´t know why don´t work
my configuration es like this, i apressiate your help, i maked donation.

This is a2billing_check_account.php


Code wrote:
#!/usr/bin/php -q
<?php
/***************************************************************************
* a2billing_check_account.php
*
* 13 April 2007
* Purpose: To check account of each Users and send an email if the balance is less than the first argument.
* Copyright 2007 User : Belaid Arezqui
* ADD THIS SCRIPT IN A CRONTAB JOB
*
* The sample above will run the script every day of each month at 6AM
crontab -e
0 6 1 * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_check_account.php


field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

****************************************************************************/
//exit();
// CHECK ALL AND ENSURE IT WORKS / NOT URGENT

set_time_limit(0);
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));


include (dirname(__FILE__)."/../db_php_lib/Class.Table.php");
include (dirname(__FILE__)."/../Class.A2Billing.php");
include (dirname(__FILE__)."/../Misc.php");



$verbose_level=0;
$groupcard=5000;

$min_credit = 5.00;

$A2B = new A2Billing();
$A2B -> load_conf($agi, NULL, 0, $idconfig);

write_log(LOGFILE_CRONT_CHECKACCOUNT, basename(__FILE__).' line:'.__LINE__."[#### BATCH BEGIN ####]");

if (!$A2B -> DbConnect()){
echo "[Cannot connect to the database]\n";
write_log(LOGFILE_CRONT_CHECKACCOUNT, basename(__FILE__).' line:'.__LINE__."[Cannot connect to the database]");
exit;
}
//$A2B -> DBHandle
$instance_table = new Table();


$QUERY = "SELECT mailtype, fromemail, fromname, subject, messagetext, messagehtml FROM cc_templatemail WHERE mailtype='reminder' ";
$listtemplate = $instance_table -> SQLExec ($A2B -> DBHandle, $QUERY);


if (!is_array($listtemplate)){
echo "[Cannot find a template mail for reminder]\n";
write_log(LOGFILE_CRONT_CHECKACCOUNT, basename(__FILE__).' line:'.__LINE__."[Cannot find a template mail for reminder]");
exit;
}
$gen_card = $listtemplate[4];
//list($mailtype, $frommail, $fromname, $subject, $messagetext, $messagehtml) = $listtemplate[0];
if ($FG_DEBUG == 1) echo "<br><b>mailtype : </b>$mailtype</br><b>from:</b> $from</br><b>fromname :</b> $fromname</br><b>subject</b> : $subject</br><b>ContentTemplate:</b></br><pre>$messagetext</pre></br><hr>";



// CHECK AMOUNT OF CARD ON WHICH APPLY THE CHECK ACCOUNT SERVICE
$QUERY = "SELECT count(*) FROM cc_card WHERE (activated='1' or activated='t') AND credit < $min_credit";

$result = $instance_table -> SQLExec ($A2B -> DBHandle, $QUERY);
$nb_card = $result[0][0];
$nbpagemax=(intval($nb_card/$groupcard));
if ($verbose_level>=1) echo "===> NB_CARD : $nb_card - NBPAGEMAX:$nbpagemax\n";

if (!($nb_card>0)){
if ($verbose_level>=1) echo "[No card to run the Recurring service]\n";
write_log(LOGFILE_CRONT_CHECKACCOUNT, basename(__FILE__).' line:'.__LINE__."[No card to run the check account service]");
exit();
}


write_log(LOGFILE_CRONT_CHECKACCOUNT, basename(__FILE__).' line:'.__LINE__."[Number of card found : $nb_card]");



// BROWSE THROUGH THE CARD TO APPLY THE CHECK ACCOUNT SERVICE
$sql = "SELECT id, credit, username, email FROM cc_card WHERE (activated='1' or activated='t') AND credit < $min_credit ORDER BY id ";
if ($verbose_level>=1) echo "==> SELECT CARD QUERY : $sql\n";
$result_card = $instance_table -> SQLExec ($A2B -> DBHandle, $sql);

foreach ($result_card as $mycard){
if ($verbose_level>=1) print_r ($mycard);
if ($verbose_level>=1) echo "------>>> ID = ".$mycard[0]." - CARD =".$mycard[2]." - BALANCE =".$mycard[1]." \n";

// SEND NOTIFICATION
if (strlen($mycard[3])>0){ // ADD CHECK EMAIL
$mail_tile = $mail_content = "LOW BALANCE : You have less than $min_credit dollars";
$mail_content = $listtemplate[0][4];
$mail_content = str_replace('$card_gen',$mycard[2],$mail_content);
$mail_content = str_replace('$balance',$mycard[1],$mail_content);
mail($mycard[3], $mail_tile, $mail_content,"[email protected]");
write_log(LOGFILE_CRONT_CHECKACCOUNT, basename(__FILE__).' line:'.__LINE__."[SENT EMAIL TO: ]".$mycard[3]);

}
}

if ($verbose_level>=1) echo "#### END RECURRING CHECK ACCOUNT \n";
write_log(LOGFILE_CRONT_CHECKACCOUNT, basename(__FILE__).' line:'.__LINE__."[#### BATCH PROCESS END ####]");


?>

i maked the comand for the contab
my contrab is like this


0 6 1 * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_check_account.php
#* * * * * /var/lib/asterisk/a2billing/callback-daemon/a2billing-callback-daemon-stop
#* * * * * /var/lib/asterisk/a2billing/callback-daemon/a2billing-callback-daemon-start
* * * * * /sbin/service a2billing-callback-daemon restart
0 * * * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_alarm.php
0 * * * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_alarm.php
0 12 * * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_batch_process.php
0 2 * * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_bill_diduse.php
0 6 1 * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_check_account.php
0 6 1 * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_invoice_cront.php
0 6 1 * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_subscription_fee.php
0 6 * * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/currencies_update_yahoo.php
0 */1 * * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/a2billing_check_account.php

thanks

diego waizer
:)




Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 22, 2008 3:40 pm 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
If you send an email manually by using the 'mail' command does it arrive?
Code:
# mail -s 'Test message' [email protected]
This is a test message.

.
Terminate the email with '<Enter><Enter>.<Enter>'. If this email isn't delivered you'll need to fix your outbound mail on the server. Consult your distribution's documentation for help with this.

Is cron actually running and trying to launch A2B's cron jobs? On my machine the cron logfile is at /var/log/cron.log.


Top
 Profile  
 
 Post subject: thanks you stavros now is it working really good.
PostPosted: Sun Jun 22, 2008 7:21 pm 
Offline

Joined: Fri Jan 18, 2008 1:33 am
Posts: 4
Location: buenos aires
i had bad settiing the smtp.
thanks you stavros now is it working really good.

bye
diego


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 9:52 am 
Offline
User avatar

Joined: Thu Jan 18, 2007 5:37 pm
Posts: 131
Location: Mallorca / Spain
i do not even have a cron.log :/

what can i do now?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 
Hosted Voice Broadcast


All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group