Answers.Body: <p>You can't use <a href="https://craftcms.stackexchange.com/questions/722/can-we-use-php-in-our-templates-instead-of-twig">PHP in a Twig template</a>.</p>
  
  <p>A plugin Craft plugin would be the easiest way to pull off what you're looking for.  I've added an answer to your other <a href="https://craftcms.stackexchange.com/questions/19861/what-is-the-best-way-to-generate-email-messages-with-attachments-from-twig-files">related question</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-09T23:12:59.683Z
Answers.LastActivityDate: 2017-04-09T23:12:59.683Z
Answers.UserDisplayName: Brad Bell
Body: <p>This is probably a newby question, but, I am just trying to add a basic email send test and my twig page does not like the dollar signs.  Is EmailModel built-in to craft or is there a plugin I need?</p>
  
  <p>I am just trying to add this code to a basically empty twig page:</p>
  
  <pre><code>$email = new EmailModel();
  $email-&gt;subject = "Thanks!";
  $email-&gt;htmlBody = "&lt;h1&gt;Congratulations!&lt;/h1";
  $email-&gt;htmlBody .= "&lt;p&gt;Hello World&lt;/p&gt;";
  $email-&gt;fromEmail = "email@domain.com";
  </code></pre>
  
  <p>thanks for the help...</p>
  
  <p>Chip</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-09T15:06:36.507Z
Comments.Text: You're adding PHP to a Twig page? Unless I'm missing something, that fundamentally doesn't make sense. Can you show us _how_ you've added this to your Twig code?
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-09T18:03:07.117Z
Comments.Text: I am transitioning from a C#/.net background to a CraftCMS/Twig/PHP platform, so, I recognized that this didn't seem to make sense, but, I couldn't find a way to easily integrate an email process into my Craft CMS site (built of twig pages) and this was the only code I have found so far.  What is the best way to do this: When a user hits a button on the site, I want a pdf file to be attached and emailed to an email address that was typed into a text box on that page.
Comments.UserDisplayName: Chip Shank
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-09T20:24:21.857Z
Comments.Text: You probably answered the question that I brought up.  I will ask my more general question as a new question. Thanks.
Comments.UserDisplayName: Chip Shank
Tags: <emails>
Title: EmailModel - Unexpected character "$"?
ThreadText: # EmailModel - Unexpected character "$"?
  
  (Asked by: username_0 on 2017-04-09)
  
  This is probably a newby question, but, I am just trying to add a basic email send test and my twig page does not like the dollar signs. Is EmailModel built-in to craft or is there a plugin I need?
  
  I am just trying to add this code to a basically empty twig page:
  
  ```
  $email = new EmailModel();
  $email->subject = "Thanks!";
  $email->htmlBody = "<h1>Congratulations!</h1";
  $email->htmlBody .= "<p>Hello World</p>";
  $email->fromEmail = "email@domain.com";
  
  ```
  
  thanks for the help...
  
  username_0
  
  **Tags:** emails
  
  > **Comments:**
  > **username_1**: You're adding PHP to a Twig page? Unless I'm missing something, that fundamentally doesn't make sense. Can you show us _how_ you've added this to your Twig code?  
  > **username_0**: I am transitioning from a C#/.net background to a CraftCMS/Twig/PHP platform, so, I recognized that this didn't seem to make sense, but, I couldn't find a way to easily integrate an email process into my Craft CMS site (built of twig pages) and this was the only code I have found so far.  What is the best way to do this: When a user hits a button on the site, I want a pdf file to be attached and emailed to an email address that was typed into a text box on that page.  
  > **username_0**: You probably answered the question that I brought up.  I will ask my more general question as a new question. Thanks.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-04-09. Score: 2 | Accepted answer
  
  You can't use [PHP in a Twig template](https://craftcms.stackexchange.com/questions/722/can-we-use-php-in-our-templates-instead-of-twig).
  
  A plugin Craft plugin would be the easiest way to pull off what you're looking for. I've added an answer to your other [related question](https://craftcms.stackexchange.com/questions/19861/what-is-the-best-way-to-generate-email-messages-with-attachments-from-twig-files).
  
  
  ---
  
  