Hi All,
At the moment I'm using ....or abusing CF to sent reminder emails for the CCnewsletter module.
CCNewsletter is a good newsletter module for Joomla! but it's missing this feature at the moment.
Since recent I'm using ChronoForms...and while I'm totally not using this tool what it was once build for...it does the work.
I'll post the code here hoping others can use it as well. I've seen many requests in the forum requesting a simulair code for different issues: but many came down to the same question: email multple different email users which are stored in a table.
This code has advantages..but it also completly abuses ChronoForms..
Joomla! 1.5.8 is used.
I will enhance the code so it will store in the table that a user has been emailed.
Then, either I'll enhance the script OR I'll create another form with a different query to sent a second reminder; again updating the number of times the user has been emailed.
Then a 3rd script (or enhanced version of the stuff below) will email the user that they are deleted and the script will delete the user.
If you have any interst in such a script please do not hesitate to sent me an email of post your request as a reply to this howto.
If you enhance the script even further, please be so kind to add your enhancement as well.
The listing of the non enabled users is a raw list. Ofcourse you can put this in a table. Might do that later as well.
Steps:
1) Create a form -> Under general: name the form.
2) Fill out the code below under FORM CODE
3) Adjust your query and ofcourse adjust the stuff you need emailed.
---> check the words in CAPITAL letters in the code below..this is the stuff you need to fill out yourself!!
That's it.
It started out as a simple test trying to get a list of users emailed from a table query..but it turned out I'm totally abusing CF and I've completly used different code. With jimport('joomla.mail.helper'); and all.
Bob: I hope you don't mind🙂
To use the form: click on the link next to your forms name in the ChronoForms Manager.
Check if all the users you want emailed are in the list and click submit...CAREFULL: there's no check if you submit it twice etc...script WILL email everytime you click.
FORM HTML:
Then in the on submit aftersending email I use this code:
That's it.
Feel free to use it...and feel free to comment on this code, the idea or post enhancements or requests for enhancements.
At the moment I'm using ....or abusing CF to sent reminder emails for the CCnewsletter module.
CCNewsletter is a good newsletter module for Joomla! but it's missing this feature at the moment.
Since recent I'm using ChronoForms...and while I'm totally not using this tool what it was once build for...it does the work.
I'll post the code here hoping others can use it as well. I've seen many requests in the forum requesting a simulair code for different issues: but many came down to the same question: email multple different email users which are stored in a table.
This code has advantages..but it also completly abuses ChronoForms..
Joomla! 1.5.8 is used.
I will enhance the code so it will store in the table that a user has been emailed.
Then, either I'll enhance the script OR I'll create another form with a different query to sent a second reminder; again updating the number of times the user has been emailed.
Then a 3rd script (or enhanced version of the stuff below) will email the user that they are deleted and the script will delete the user.
If you have any interst in such a script please do not hesitate to sent me an email of post your request as a reply to this howto.
If you enhance the script even further, please be so kind to add your enhancement as well.
The listing of the non enabled users is a raw list. Ofcourse you can put this in a table. Might do that later as well.
Steps:
1) Create a form -> Under general: name the form.
2) Fill out the code below under FORM CODE
3) Adjust your query and ofcourse adjust the stuff you need emailed.
---> check the words in CAPITAL letters in the code below..this is the stuff you need to fill out yourself!!
That's it.
It started out as a simple test trying to get a list of users emailed from a table query..but it turned out I'm totally abusing CF and I've completly used different code. With jimport('joomla.mail.helper'); and all.
Bob: I hope you don't mind🙂
To use the form: click on the link next to your forms name in the ChronoForms Manager.
Check if all the users you want emailed are in the list and click submit...CAREFULL: there's no check if you submit it twice etc...script WILL email everytime you click.
FORM HTML:
<?php
$database =& JFactory::getDBO();
$query = "SELECT id,name,email, enabled FROM jos_ccnewsletter_subscribers WHERE enabled = '0' ";
$result = mysql_query($query) or die ('Error, insert query failed'.mysql_error());
while($row = mysql_fetch_array($result)) {
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$code = md5($id) ;
echo "These users will be emailed:<br> $id,| $name, | $email | $code <br>";
}
?>
<input value="Submit" name="undefined" type="submit">
Then in the on submit aftersending email I use this code:
<?php
$database =& JFactory::getDBO();
$query = "SELECT id,name,email, enabled FROM jos_ccnewsletter_subscribers WHERE enabled = '0' AND name = 'lkjkl'";
$result = mysql_query($query) or die ('Error, insert query failed'.mysql_error());
while($row = mysql_fetch_array($result)) {
$id = $row['id'];
$name = $row['name'];
$email = $row['email'];
$code = md5($id) ;
echo "These users will be emailed:<br> $id,| $name, | $email | $code <br>";
}
$mailcode="http://www.DOMAIN.TLD/index.php?option=com_ccnewsletter&task=activate&code=$code" ;
$subject = "YOUR SUBJECT";
$html_message= "DEAR $name,<br><br>YOUR TEXT. U CAN USE HTML CODE HERE. <br>THE LINK TO REGISTER : <a href='$mailcode'>CLICK TO REGISTER</a><br><br>MORE TEXT. <br><br>KIND REGARDS,<br><br>YOURDOMAIN.TLD<br><br>";
$fromName = "YOURFROMNAME";
$fromEmail="YOURFROMEMAIL";
jimport('joomla.mail.helper');
$mail = JFactory::getMailer();
$mail->addRecipient( $email );
$mail->setSender( array( $fromEmail, $fromName ) );
$mail->addReplyTo( array( $fromEmail, $fromName ) );
$mail->setSubject( $subject );
$mail->setBody( $html_message );
$mail->IsHTML(true);
$sent = $mail->Send();
}
?>
That's it.
Feel free to use it...and feel free to comment on this code, the idea or post enhancements or requests for enhancements.