Example #1
0
 /** 
  * Send email message.
  */
 function SendEmailMessage($Recipient, $Subject, $Message, $Options = False)
 {
     $MimeType = ArrayValue('MimeType', $Options, 'text/plain');
     $SenderEmail = ArrayValue('SenderEmail', $Options, '');
     $SenderName = ArrayValue('SenderName', $Options, '');
     $Email = new Gdn_Email();
     $Result = $Email->From($SenderEmail, $SenderName)->MimeType($MimeType)->Subject($Subject)->To($Recipient)->Message($Message)->Send();
     return $Result;
 }
Example #2
0
 public function PasswordRequest($Email)
 {
     $User = $this->GetWhere(array('Email' => $Email))->FirstRow();
     if (!is_object($User) || $Email == '') {
         return FALSE;
     }
     $PasswordResetKey = RandomString(6);
     $this->SaveAttribute($User->UserID, 'PasswordResetKey', $PasswordResetKey);
     $AppTitle = Gdn::Config('Garden.Title');
     $Email = new Gdn_Email();
     $Email->Subject(sprintf(Gdn::Translate('[%s] Password Reset Request'), $AppTitle));
     $Email->To($User->Email);
     $Email->From(Gdn::Config('Garden.Support.Email'), Gdn::Config('Garden.Support.Name'));
     $Email->Message(sprintf(Gdn::Translate('PasswordRequest'), $User->Name, $AppTitle, Url('/entry/passwordreset/' . $User->UserID . '/' . $PasswordResetKey, TRUE)));
     $Email->Send();
     return TRUE;
 }
Example #3
0
 public function Send($InvitationID)
 {
     $Invitation = $this->GetByInvitationID($InvitationID);
     $Session = Gdn::Session();
     if ($Invitation === FALSE) {
         throw new Exception(T('ErrorRecordNotFound'));
     } else {
         if ($Session->UserID != $Invitation->SenderUserID) {
             throw new Exception(T('ErrorPermission'));
         } else {
             // Some information for the email
             $RegistrationUrl = CombinePaths(array(Gdn::Request()->WebPath(TRUE, FALSE), 'entry', 'register', $Invitation->Code), '/');
             $AppTitle = Gdn::Config('Garden.Title');
             $Email = new Gdn_Email();
             $Email->Subject(sprintf(T('[%s] Invitation'), $AppTitle));
             $Email->To($Invitation->Email);
             $Email->From($Invitation->SenderEmail, $Invitation->SenderName);
             $Email->Message(sprintf(T('EmailInvitation'), $Invitation->SenderName, $AppTitle, $RegistrationUrl));
             $Email->Send();
         }
     }
 }
Example #4
0
 public function SendNotification($ActivityID, $Story = '')
 {
     $Activity = $this->GetID($ActivityID);
     if (!is_object($Activity)) {
         return;
     }
     $Story = Format::Text($Story == '' ? $Activity->Story : $Story);
     // If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
     if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
         $CommentActivity = $this->GetID($Activity->CommentActivityID);
         $Activity->RegardingUserID = $CommentActivity->RegardingUserID;
         $Activity->Route = '/profile/' . $CommentActivity->RegardingUserID . '/' . Format::Url($CommentActivity->RegardingName) . '/#Activity_' . $Activity->CommentActivityID;
     }
     $User = $this->SQL->Select('Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
     if ($User) {
         $Preferences = Format::Unserialize($User->Preferences);
         $Preference = ArrayValue('Email.' . $Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.' . $Activity->ActivityType));
         if ($Preference) {
             $ActivityHeadline = Format::Text(Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID));
             $Email = new Gdn_Email();
             $Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
             $Email->To($User->Email, $User->Name);
             $Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName'));
             $Email->Message(sprintf(T($Story == '' ? 'EmailNotification' : 'EmailStoryNotification'), $ActivityHeadline, Url($Activity->Route == '' ? '/' : $Activity->Route, TRUE), $Story));
             try {
                 $Email->Send();
             } catch (Exception $ex) {
                 // Don't do anything with the exception.
             }
         }
     }
 }