Trouble extending an event

Permalink
Hey guys,

I want to send an email to a user upon activation of his profile. For this I extend the on_user_activate event:

<?php 
Events::extend('on_user_activate', 'OnActivation', 'sendActivationMail', 'mail/on_activation.php');
?>


This works and the event is extended and on_activation.php is 'called'. However I get the following error message:

"Parse error: syntax error, unexpected T_STRING, expecting ';' or '{' in /mail/on_activation.php on line 4" (which is the line with public function…)

The on_activation.php looks like this:

<?php defined('C5_EXECUTE') or die("Access Denied.");
class OnActivation {
   public function sendActivationMail($user) {
      $mh = Loader::helper('mail');      
      $userEmailAddress = $user->uEmail;
      $mh->to($userEmailAddress);
      $mh->load('user_activation_mail_template');
      $mh->sendMail();
   }   
}


I'm a bit at a loss here. Obviously I'm overlooking something stupid. Can you help? Thanks!

mckoenig
 
andrew replied on at Permalink Best Answer Reply
andrew
That is a stumper. The code looks totally fine to me. Could there be some funky Unicode characters in there that are invisible?

Sent from my iPhone
mckoenig replied on at Permalink Reply
mckoenig
Oh well, it seems like it had been some text encoding trouble. Converted it to UTF-16 and now it works. Veeeeery strange.

Thank you Andrew.
mckoenig replied on at Permalink Reply
mckoenig
One more problem with this code, maybe you can provide a hint for that one, too. The mail helper doesn't seem to do much here. Regardless if I set the $mh->to to a hardcoded email address and also regardless if I try to use a template or not. No mail seems to be sent. Am I missing something?

Thanks!
mckoenig replied on at Permalink Reply
mckoenig
Sorry to bump this, but does anyone have an idea what is preventing the mail helper from sending mail in this code? Thanks!