I am using Zend_View for text to text content of a template. However, I ran into one problem that I could not solve: if the line ends with a php block (?>), Then the line break is lost.
Does anyone know how I can solve this?
The application uses the Zend framework, but I have no particular reason to use Zend_View to render the email template (except that it looked the easiest and most obvious way to do this), so if there is an alternative solution, that would be good.
I tried to examine the original text output, and line breaks are completely lost. There is no "\ r" or "\ n" to see, so I cannot replace anything.
Code for sending email:
$ emailView = new Zend_View ();
$ emailView-> setScriptPath (realpath (FRONTEND_APPLICATION_PATH. '/ .. / email /'));
$ bodyText = $ emailView-> render ('recruitment-job-alert-text.phtml');
// $ model = new Model_VacancyDetail ();
// $ model-> find (1);
// $ emailView-> vacancyDetail = $ model;
$ mail = new Zend_Mail ();
$ mail-> setSubject ('Job Alert:'. $ model-> references ['vacancy_type']);
$ mail-> addTo ($ fromEmail, $ fromName);
$ mail-> setFrom ($ fromEmail, $ fromName);
$ mail-> setBodyHtml ($ bodyHtml);
$ mail-> setBodyText ($ bodyText);
$ mail-> send ();
Email Template Content:
Title: <? = $ This-> escape ($ this-> vacancyDetail-> references ['vacancy_type'])?>
Location: <? = $ This-> vacancyDetail-> references ['name']?>
Department: <? = $ This-> vacancyDetail-> references ['department_name']?>
Require Driving License: <? = ($ This-> vacancyDetail-> requireDrivingLicence == 1)? 'Yes': 'No'?>
Working Hours: <? = $ This-> vacancyDetail-> workingHours?>.
Benefits: <? = $ This-> vacancyDetail-> benefits?>.
Salary: <? = $ This-> vacancyDetail-> salary?>.
Details:
<? = strip_tags ($ this-> vacancyDetail-> description)?>
Apply now at http://www.example.com/recruitment
Example of received email content:
Title: Example Vacancy Type
Location: Example LocationDepartment: Example DepartmentRequire Driving License: YesWorking Hours: 40.
Benefits: Company car.
Salary: £ 15,000pa.
Details:
This is an example position. It does not really exist.
Apply now at http://www.example.com/recruitment
source share