Expiration email question

13 years 4 months ago #149278 by nant
Replied by nant on topic Re:Expiration email questi
Aly wrote:

Am wondering the same thing in both cases. I sent Rod an email but didn't get a response and am unsure whether this feature made it into 1.1.12 I would really love to be able to give my users a head's up when their membership is about to expire.


Automated Marketing Email feature did not make it into CBSubs 1.1.2 (high priority for CBSubs 1.2).

However, you can use the CB User Manager to filter against CBSubs plan members and then further filter against expiration date criteria. Then you can Mass Email the resulting set.

Please Log in to join the conversation.

13 years 3 months ago #151199 by RCheesley
Replied by RCheesley on topic Re:Expiration email questi
Not sure if this works any more. I had a mail from my client today saying that the email notifications have stopped working, which coincides with me updating CB (note I've not updated CBSubs yet as I wanted to be sure CB update went OK before doing CBSubs).

Any feedback as to why it might not be working would be great as it's a key feature - can't quite believe it didn't make it into the new version, guess there must have been stuff that was more important huh!

Ruth

Ruth Cheesley
Joomla Specialist
Virya Technologies Ltd.

Please Log in to join the conversation.

13 years 3 months ago - 13 years 3 months ago #151200 by RCheesley
Replied by RCheesley on topic Re:Expiration email questi

However, you can use the CB User Manager to filter against CBSubs plan members and then further filter against expiration date criteria. Then you can Mass Email the resulting set.


When you have lots of users expiring each day, this is not exactly a task that I can reasonably ask a client to do manually on a daily or even weekly basis. Are you suggesting there is a way of automating the above?

Ruth

Ruth Cheesley
Joomla Specialist
Virya Technologies Ltd.

Please Log in to join the conversation.

13 years 3 months ago #151204 by ThePiston
Replied by ThePiston on topic Re:Expiration email questi
I think mine is working well. I did have to put all of my queries into separate files though but I think that's unrelated to CB upgrade. Are you using the custom component or the single php file/cron method?

CB 2.3, CBsubs 4.3, PHP 7.1, J! 3.9.X

Please Log in to join the conversation.

13 years 3 months ago #151370 by RCheesley
Replied by RCheesley on topic Re:Expiration email questi
Hiya,

I'm using the component PHP file which I wrote about earlier in the post. Would you be able to send me your files/instructions so I can test that out?

Ruth

Ruth Cheesley
Joomla Specialist
Virya Technologies Ltd.

Please Log in to join the conversation.

13 years 3 months ago - 13 years 3 months ago #151383 by ThePiston
Replied by ThePiston on topic Re:Expiration email questi
It's easy - one file you can either run by just going to it in a browser. I added some text so if the query was successful, you will see a success message when run so you know it is working. Thanks to rodsdesign for the original code. Once you know this is working by running it manually in a browser, you can add it as a cron task. Ask your host for the proper cron syntax as each is a little different for each host. I run all of mine once per day in the early morning. I have 9 files - each hasa different query for each plan ID and a unique message for each but you can easily make one query for all of your member types. There is probably a way to put all of the queries into one file, but I could not get it to work and I was in a time crunch so I just created one file for each query.

Copy all of this into a new php file on your server. Then run the file in a browser to see if you get the success message. Follow the commented out instructions in the code:
<?php 
//change these to your values
$username="sqlusername";
$password="sqlpassword";
$database="sql_dbname";
$hostname="localhost";

//leave this alone
$today=date('Y-m-d');

// Opens a connection to a mySQL server - leave alone
$connection=mysql_connect ($hostname, $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}

// Set the active mySQL database - leave alone
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Cant use db : ' . mysql_error());
}

//change these to reflect your times - 1 day = 24hrs so 4 weeks = 672 hrs, etc, leave the 3600 alone
//you only need one of these per query but I put them all in each of my files

$week4 = strtotime($today) + 672*3600; 
$week3 = strtotime($today) + 504*3600;
$week2 = strtotime($today) + 336*3600;
$week1 = strtotime($today) + 168*3600;
$zero = strtotime($today) + 24*3600;   //  (hint) 'today' works better if you had 24 hours

//leave these alone unless you change the $XXX values above.  Do not start a variable with a number like this $4week - that's a no no
$expire= date('Y-m-d', $week4);
$expire2= date('Y-m-d', $week3);
$expire3= date('Y-m-d', $week2);
$expire4= date('Y-m-d', $week1);
$expire5= date('Y-m-d', $zero);

// 1 week GENERIC (name of this query - this query grabs all of my 'generic' members 1 week from their expiration
//change the plan_id to whatever value you need
//leave out the plan_id line all together if you want to query all Plans
//this particular query grabs all members except ones with plan_id = 1

//these $expire variables in the query need to match the one above that you want for this query be it one week or whatever
$q="SELECT jos_cbsubs_subscriptions.status, jos_cbsubs_subscriptions.user_id, 
jos_cbsubs_subscriptions.plan_id, jos_cbsubs_subscriptions.expiry_date, jos_comprofiler.firstname, 
jos_comprofiler.lastname, jos_users.email
FROM jos_cbsubs_subscriptions, jos_users, jos_comprofiler
WHERE jos_cbsubs_subscriptions.user_id = jos_users.id
AND jos_cbsubs_subscriptions.status = 'A'
AND jos_users.block = 0
AND jos_cbsubs_subscriptions.plan_id != 1
AND jos_cbsubs_subscriptions.expiry_date > '$expire4 00:00:00' 
AND jos_cbsubs_subscriptions.expiry_date < '$expire4 23:59:59'
AND jos_cbsubs_subscriptions.user_id = jos_users.id
AND jos_comprofiler.user_id = jos_users.id";
        
$r=mysql_query($q);

//this will show you a message when you run the file manually so you can see if it works, change the message to your liking
if (!$r) {
  die('Invalid query: ' . mysql_error());
}
else {
	echo "<font color='green'>Success 1week generic!</font><br />";
}

while ($rr=mysql_fetch_array($r)) {

$day=$rr[expiry_date];
$ex_date=date('l, F j, Y',strtotime($day));

//this is the message you send - be sure to include a link back to your site to make it easy
//You can use HTML and single quotes, but no double quotes in between the double quotes! 
//so be careful when adding links to only use single quotes
$message="Dear $rr[firstname], <br /><br />
<b>Your membership expires in 1 week!<b><br /><br />Please <a href='http://www.mysites.com'>click here</a> to renew.<br /><br />Thank You";

//change subject line to your liking
$subject="Your membership expires in 1 Week";
$recipient = $rr[email];

//leave all of this alone unless you know what you're doing
    $body = "<html>\n";
    $body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#000;\">\n";
    $body = $message;
    $body .= "</body>\n";
    $body .= "</html>\n";
   
//change all of these to whatever emails you need, change NAME to what you want people to see in their inbox
    $headers  = "From: NAME <webadmin@yoursite.com>\r\n";
    $headers .= "Reply-To: name@email.com\r\n";
    $headers .= "Return-Path: name@email.com\r\n";
    $headers .= 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     
    return mail($recipient, $subject, $message, $headers);
  } 

?>

CB 2.3, CBsubs 4.3, PHP 7.1, J! 3.9.X

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.272 seconds