File modules/cms/action/profile/ProfileMailAction.class.php
Last commit: Sat Oct 17 02:16:28 2026 +0200 Jan Dankert Refactoring: Removed empty view() and post() methods; OpenAPI cleanup, removed these unused paths.
1 <?php 2 namespace cms\action\profile; 3 use cms\action\Method; 4 use cms\action\ProfileAction; 5 use language\Messages; 6 use logger\Logger; 7 use util\exception\ValidationException; 8 use util\mail\Mail; 9 use util\Session; 10 use util\text\TextMessage; 11 12 class ProfileMailAction extends ProfileAction implements Method { 13 14 15 16 public function post() { 17 srand ((float)microtime()*1000003); 18 $code = rand(); // Zufalls-Freischaltcode erzeugen 19 $newMail = $this->request->getText('mail'); 20 21 if ( !$newMail ) 22 { 23 // Keine E-Mail-Adresse eingegeben. 24 throw new ValidationException('mail'); 25 } 26 else 27 { 28 // Der Freischaltcode wird in der Sitzung gespeichert. 29 Session::set( Session::KEY_MAIL_CHANGE_CODE,$code ); 30 Session::set( Session::KEY_MAIL_CHANGE_MAIL,$newMail); 31 32 // E-Mail an die neue Adresse senden. 33 $mail = new Mail($newMail, Messages::MAIL_SUBJECT_MAIL_CHANGE_CODE,Messages::MAIL_TEXT_MAIL_CHANGE_CODE); 34 $mail->setVar('code',$code ); 35 $mail->setVar('name',$this->user->getName()); 36 37 try { 38 $mail->send(); 39 $this->addNoticeFor( $this->user, Messages::MAIL_SENT); 40 } catch( \Exception $e ) { 41 Logger::warn( new \Exception( TextMessage::create('Mail could not be sent for user ${name} with the new email adress ${mail} ',['name'=>$this->user->name,'mail'=>$newMail]),0,$e) ); 42 $this->addErrorFor($this->user, Messages::MAIL_NOT_SENT ); 43 } 44 } 45 } 46 }
Downloadmodules/cms/action/profile/ProfileMailAction.class.php
History Sat, 17 Oct 2026 02:16:28 +0200 Jan Dankert Refactoring: Removed empty view() and post() methods; OpenAPI cleanup, removed these unused paths. Thu, 15 Oct 2026 01:39:59 +0200 Jan Dankert New: A much better generation of the OpenAPI Interface documents, supports now the UI API Objects. Wed, 27 Oct 2021 02:27:59 +0200 Jan Dankert Refactoring: Splitted the mail client into a.) sendmail and b.) smtp. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Thu, 19 Nov 2020 16:05:15 +0100 Jan Dankert Refactoring: Better exception handling in class Mail; multiple CC and BCC receivers. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.