php - Text email template in using Zend_View losing line breaks -


I am using Zend_View for template text email content. However, I encounter a problem that I could not solve: if a line ends with a php block (?>), Then line breaks are lost.

Do anyone have any ideas, can I solve it?

This application is using the Zend Framework, but I have no specific reason to use Zend_View to present an email template (except that it is the easiest, most obvious to do this Method), so if there is an alternative solution, then it would be good.

I have tried to check raw text production, and the linebreak is completely lost. No "\ r" or "\ n" has to be seen, so nothing is left which I can change.

Email sending code:

 $ emailView = new Zend_View (); $ EmailView-> Setscape Path (actual path (front END_APPLICATION_PATH. '/ .. / email /')); $ BodyText = $ emailView-> Render ('recruitment-job-alert-text.phtml'); // $ model = new Model_VacancyDetail (); // $ Model-> Search (1); // $ emailView-> blankDefil = $ model; $ Mail = new Zend_Mail (); $ Mail-> setSubject ('Job Alert:' $ model-> context ['vacancy_type']); $ Mail-> addTo ($ email, $ fromName); $ Mail-> setFrom ($ email, $ fromName); $ Mail-> setBodyHtml ($ bodyHtml); $ Mail-> setBodyText ($ bodyText); $ Mail> Send (); 

Email Template Content:

 Title: & lt ;? = $ This-> escape ($ -> empty-detail-> context ['vacancy_type'])> Location: & lt; ? = $ This-> vacancyDetail-> context ['name']?> Department: & lt ;? = $ This-> vacancyDetail-> reference ['department_name']?> Driving license is required:  Space Dictatorie-> Dering Lycans == 1) Needed? 'Yes': 'No'?> Working hours: & lt ;? = $ This-> Vaccineri-> Employed?> Benefits: & lt ;? = $ This-> Vacancy Dictity-> Benefits? Salary: & lt ;? = $ This-> Vacancy Dupet-> Pay? Details: & lt ;? = Strip_tags ($ the-> vacancyDetail-> description)?> Apply now to http://www.example.com/recruitment 

Example of email content as a result:

 heading Example: Place of free place: Example Location: Department: Example Department Driving License required: Yes Working time: 40. Profit: Company car pay: £ 15,000pa Description: This is an example situation. It does not actually exist now apply to http://www.example.com/recruitment 

I believe that after the PHP is eating new line?>. Generally this is a good thing, but I can see why it is bothering you in your case.

You probably will need to do something like this:

  Title:  Reference Name']. "\ N"? & Gt; Department: & lt ;? = $ This- & gt; Blank descriptor-> Reference ['department_name']. "\ N"? & Gt;  

Edit:

There is a reference to confirm that I am not mad:

Why is this a good thing? Imagine well your email template:

  Title: & lt ;? = $ This- & gt; Escape ($ is- &;; vacancyDetail-> context ['vacancy_type']). "\ N"? & Gt; & Lt ;? Php if (empty ($ this-> empty dip-> context ['name'])) {? & Gt; Location: & lt ;? = $ This- & gt; Empty dip-> Reference Name']. "\ N"? & Gt; & Lt ;? Php}? & Gt; Department: & lt ;? Php foreach ($ this-> vacancies- detail-> context ['department'] as $ dept {? & Gt; & Lt ;? = $ Dept->. Name "\ n" & gt; & Lt ;? Php}? & Gt; In that situation, you really do not want to eliminate many new lines between each line of output (a problem that I recently created an email template for a non-PHP project. In) 

Another option for you is that you do not keep your template in PHP, just use {name}, {department_name}, or equalize your variable and then parse them.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -