Sending mail with external template
Permalink
Hello,
In my blocks controller i am sending an email to an email adress. This works without issue. However, I want to load a mail template from the mail/ directory, but whenever i do, the email is sent but on the page i receive an error message saying:
Warning: Cannot modify header information - headers already sent by (output started at /home/devlevel/public_html/ndestates/concrete/core/helpers/mail.php:123) in /home/devlevel/public_html/ndestates/concrete/core/libraries/view.php on line 917
I am using the exact code from the send mail concret5 website. I am unsure why i see this error. Any advice would be appreciated:
In my blocks controller i am sending an email to an email adress. This works without issue. However, I want to load a mail template from the mail/ directory, but whenever i do, the email is sent but on the page i receive an error message saying:
Warning: Cannot modify header information - headers already sent by (output started at /home/devlevel/public_html/ndestates/concrete/core/helpers/mail.php:123) in /home/devlevel/public_html/ndestates/concrete/core/libraries/view.php on line 917
I am using the exact code from the send mail concret5 website. I am unsure why i see this error. Any advice would be appreciated:
in my controller: $mh = Loader::helper('mail'); $mh->to('myemailadress@email.com', 'My Name'); $mh->from('noreply@concrete5.org'); $mh->load('book_viewing'); $mh->sendMail(); in mail/book_viewing.php $subject = t("My subject"); $body = t(" My message here.... ";
Hi,
Thanks for te response.
No that doesnt work im afraid....
Even if i move the subject and the body into the main controller, then load a blank template it still provides the error..?
Thanks for te response.
No that doesnt work im afraid....
Even if i move the subject and the body into the main controller, then load a blank template it still provides the error..?
Make sure there are no spaces before your <?php tags in your template file. I'm not sure if this affects anything also, but make sure in your template file that you are not closing the php tags (i.e get rid of ?> if it's there.)
or like this: