Sending Email With Attachment In Schedule Task Not Working

teoyh

Member
I had created a schedule php task to send out email with an attachment ;

I created a php with the following
<?php
defined('_JEXEC') or die();
$db = FabrikWorker::getDbo(false, 3);
$db->setQuery("SELECT attachment FROM stm_change_req where id='11'");
$docattach = $db->loadResult();
$strcount = strlen($docattach);
if($strcount!==0){
$filelen = $strcount - 30;
$docfile = 'images/change'.substr($docattach,30,$filelen);
$attachment[] = $docfile;
}
$email = "test@test.com";
$subject ="Testing";
$message ="Testing";
$res = FabrikWorker::sendMail($MailFrom, $FromName, $email, $subject, $message,true,$Cc,$Bcc,$attachment,$replyto,$replytoname);
?>

The email was send but the attachment was not sent.
I tested the above in List Plugin Php no issue , can someone help me with this , thank you in advance
 
For the benefit of those who encounter the same problem as me , i realise i need to add the JPATH_ROOT in front of the attachment folder path

$docfile = JPATH_ROOT.'/images/change'.substr($docattach,30,$filelen);

Not sure what had change last time i do not need to do that and it will still work !
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top