Hi,
How to parse description contains html tags while sending email to user programmatically?
My code:
"
$oTemplate = new EmailTemplate();
$oMail = new SugarPHPMailer();
$oEmailObj = new Email();
$oTemplate->retrieve_by_string_fields(array('name' => "Template Name", 'type' => 'email'));
$defaults = $oEmailObj->getSystemDefaultEmail();
$oMail->From = $defaults['email'];
$oMail->FromName = $defaults['name'];
$oMail->ClearAllRecipients();
$oMail->ClearReplyTos();
$oMail->AddAddress($oUser->email1, $oUser->full_name);
$test = $oUser->full_name;
$oMail->Subject = parse_alert_template($oTask, $oTemplate->subject);
$body = parse_alert_template($oTask, $oTemplate->body_html);
$description = strip_tags($oTask->description);
$body = str_replace('$task_description',$description,$body);
$oMail->Body_html = from_html($body);
$oMail->Body = wordwrap($body, 900);
$oMail->Body = $body;
$oMail->IsHTML(true);
$oMail->prepForOutbound();
$oMail->setMailerForSystem();
"
$task_description is variable in email template, so tried to replace using strip_tags($oTask->description) to parse html content, but
not working as expected and $oTask->description contains data like :
"Dear Sugar Administrator,<br /> On XXX, XXX Xth 1555 , beginning Time, SugarCRM will be performing maintenance. Maintenance is expected to be complete.<br /> Please note that this only affect you if you are using tXXX service.<br /> "
Current Output -
"Dear Sugar Administrator,On XXX, XXX Xth 1555 , beginning Time, SugarCRM will be performing maintenance. Maintenance is expected to be complete.Please note that this only affect you if you are using tXXX service."
Expected output -
"Dear Sugar Administrator,
On XXX, XXX Xth 1555 , beginning Time, SugarCRM will be performing maintenance. Maintenance is expected to be complete.
Please note that this only affect you if you are using tXXX service."
Thanks,
Shreya