title: Using $this when not in object context - ZendFramework
body: <p>This is driving me nuts.</p>
  
  <p>Downloaded and installed ZendFramework. Trying to send a DKIM signed mail but it is giving me this error(which i copied directly off their documentation).</p>
  
  <p>Error: Fatal error: Uncaught Error: Using $this when not in object context in C:\xampp\htdocs\Project\send_form_email.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Project\send_form_email.php on line 12</p>
  
  <pre><code>// sign message with dkim
  $signer = $this-&gt;getServiceLocator()-&gt;get('DkimSigner');
  $signer-&gt;signMessage($mail);
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>Edit: Added all coding</p>
  
  <pre><code>&lt;?php
  
  require 'vendor/autoload.php';
  
  $mail = new \Zend\Mail\Message();
  $mail-&gt;setBody("Test world!");
  $mail-&gt;setFrom('noreplytest@sanscalc.co.za');
  $mail-&gt;addTo('jr.swart49995@gmail.com');
  $mail-&gt;setSubject('le subject');
  
  // sign message with dkim
  $signer = $this-&gt;getServiceLocator()-&gt;get('DkimSigner');
  $signer-&gt;signMessage($mail);
  
  // send message
  $transport = new \Zend\Mail\Transport\Sendmail();
  $transport-&gt;send($mail);
  ?&gt;
  
  Thank you for contacting us. We will be in touch with you very soon.
  
  &lt;?php
  
  }
  ?&gt;
  </code></pre>