How to... email auto responders?

Yes, we have a helper for that, FabrikHelperHTML::getContentTemplate() ...

Code:
    /**
    * Get content item template
    *
    * @param   int     $contentTemplate Joomla article id
    * @param    string $part            which part, intro, full, or both
    * @param   bool    $runPlugins      run content plugins on the text
    *
    * @since   3.0.7
    *
    * @return  string  content item html
    */
    public static function getContentTemplate($contentTemplate, $part = 'both', $runPlugins = false)

So yes, you could use an eval'ed msg, and include your own template. You'd have to do your own placeholder replacement though, as we do that before we do any eval'ing of the msg.

So something like ...

Code:
$myTmpl = FabrikHelperHTML::getContentTemplate(123, 'both', true);
return $w->parseMessageForPlaceHolder($myTmpl, $row);

... would get article 123, concatenating the intro and body of the article, run any content plugins, then do placeholder replacement. $w and $row are already defined in the plugin code that calls your code.

-- hugh

Hugh, could I use your code above, like this:

PHP:
    /**
    * Get content item template
    *
    * @param   int     $contentTemplate Joomla article id
    * @param    string $part            which part, intro, full, or both
    * @param   bool    $runPlugins      run content plugins on the text
    *
    * @since   3.0.7
    *
    * @return  string  content item html
    */
    public static function getContentTemplate($contentTemplate, $part = 'both', $runPlugins = false)

$myTmpl = FabrikHelperHTML::getContentTemplate(123, 'both', true);
return $w->parseMessageForPlaceHolder($myTmpl, $row);

In the "Message" section of the cron email plugin and it will work? Or does it need something more?

If I wanted to use it in the PHP cron plugin, I would also need to find some code somewhere to actually send an email?
 
Yes you should be able to use that in the message, as long as there's an 'eval' option for the message (not at my computer atm, can't remember). You don't need that first line (public static function) though, that was just showing the arts for the function call

For sending mail, there's a helper function as well. Search forums for sendmail.

Sent from my HTC6545LVW using Tapatalk
 
Ok cool. Thanks! Ja I wouldn't have included the commented bits.

It seems my cron emails are working properly now BTW. Thanks for all your help with this.



bj?rn
- on tapatalk
 
Hi Hugh, I hoped not to bother you about this again, but can't make out what the issue is with this. I've setup my cron email to go out and use an article as a template above, but when I run it, I run into this error. What is weird is, it seems the error has something to do with my $timediff calculation, even though, I have the exact same code running on my other site as per the rest of this thread:

An error has occurred.
0 DateTime::__construct(): Failed to parse time string (<a data-loadmethod="xhr" data-list="list_1_com_fabrik_1" class="fabrik___rowlink fabrik_edit" href="/administrator/index.php?option=com_fabrik&task=form.view&formid=1&rowid=19">2016-06-25 12:24:24</a>) at position 0 (<): Unexpected character

If I look directly in the db, I don't see any weird characters in the date_time field?

This is the code in my message field, Eval set to yes:

PHP:
public static function getContentTemplate($contentTemplate, $part = 'both', $runPlugins = false);

$myTmpl = FabrikHelperHTML::getContentTemplate(81, 'both', true);
return $w->parseMessageForPlaceHolder($myTmpl, $row);

And this is my condition:

PHP:
$date1 =new DateTime();
$date2 =new DateTime('{btcm_leads___date_time}');
$timediff = $date2->diff($date1)->format("%a");

return '{btcm_leads___follow_up_raw}' == '0' && '{btcm_leads___role_raw}' == '1' && $timediff > 0;

But from that error, it seems like a problem with the DateTime() thingy?
 
Looks like you may be using that date as a 'detail link', which is why in that error msg it's a link wrapped around the date.

Try using the _raw placeholder for the date.

-- hugh
 
I don?t understand. I literally copied and pasted that code from another script on another site? What do you mean by 'detail link'?



bj?rn
- on tapatalk
 
It seems {btcm_leads___date_time} is a complete "link to details" (the error message is showing a HTML link) but the raw date-time string is needed, so use {btcm_leads___date_time_raw}
(Maybe in you other script the element is not set to link to details or it's used in an other situation)
 
Hi @troester even though I don't really understand half of what you just tried to explain to me, changing it to _raw seems to have worked, as the email cron did run after running it manually. Thank you for that.

However, the email never came through :/ I don't understand, I have a virtually identical script on another website and it works fine, unless, the script calling the template is not set up properly? On my othe site, I am not calling an article template, I have the email template inserted in the "message" field.

Thanks for all your help guys. @troester , do you work for fabrik? Once I start making money from all these scripts I'm building, I'll be sure to start 'paying it back'.
 
I played around with this some more. It seems that it all works, but when I run it, I also get a message saying, "message body empty" and the email does not arrive. So it seems I'm missing something in the code I have in the message field. I did set Eval to 'yes'.

I know I'm pushing my luck now asking for advice about this here as it's not an issue with Fabrik. Was hoping it's just going to be straightforward and run smoothly. :/
 
I noticed yesterday. Some of my crons aren't running. The last ones that ran seems to have been the 19th of July. The weird thing is, about half of them do run and then it stops.

I believe I updated to Joomla 3.6 and also Fabrik 3.5 on that date. If I look at the logs in the db there is a warning, something about the smtp class wanting to send through my mail server using SSL but it's set to use localhost.

I'm wondering if there was some weird update with the phpmailer library.

Still doesn't explain why the first 5 would run and then not the last 5?

bj?rn
- from tapatalk
 
Since Joomla3.5? J!'s phpmailer is very sensitive about "wrong" settings which were tolerated before (string/array, empty arrays etc).

If you are doing your own mailing via php have a look at related threads in the forum and at GitHub commits addressing e.g. form email etc.
 
I've setup SMTP mailing. Remember we still had a long discussion about it a while back? Fine tuned everything so emails don't end up in spam. It's been 100% up until now.

The fact that some do go out just makes me wonder whether anything with has changed with regards to cron emails after the last update.

bj?rn
- from tapatalk
 
I changed it to use SSL now with the SSL mail server address for sending as a test. The test mail goes out fine. So will see how that goes.

I did however also find this in the logs: 8,Undefined index: rowid,/var/www/xxx/xxx/httpdocs/components/com_fabrik/router.php,231
A lot of them.
 
Ok, setting up the SSL mail server in Joomla config has gotten rid of that log entry. So that worked. Still getting the entry above though. And there is a new entry today:
8192,mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead,/var/www/xxx/xxx/httpdocs/libraries/joomla/database/driver/mysql.php,89

But only 3 out of 12 of my crons ran last night. Had to run them all manually now.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top