apps/encryption/lib/Crypto/EncryptAll.php
/**
	 * send encryption key passwords to the users by mail
	 */
send encryption key passwords to the users by mail
send encryption key passwords to the users by mail
protected function sendPasswordsByMail() {
		$noMail = [];
		$this->output->writeln('');
		$progress = new ProgressBar($this->output, count($this->userPasswords));
		$progress->start();
		foreach ($this->userPasswords as $uid => $password) {
			$progress->advance();
			if (!empty($password)) {
				$recipient = $this->userManager->get($uid);
				$recipientDisplayName = $recipient->getDisplayName();
				$to = $recipient->getEMailAddress();
				if ($to === '') {
					$noMail[] = $uid;
					continue;
				}
				$subject = (string)$this->l->t('one-time password for server-side-encryption');
				list($htmlBody, $textBody) = $this->createMailBody($password);
				try {
					$message = $this->mailer->createMessage();
					$message->setSubject($subject);
					$message->setTo([$to => $recipientDisplayName]);
					$message->setHtmlBody($htmlBody);
					$message->setPlainBody($textBody);
					$message->setFrom([
						\OCP\Util::getDefaultEmailAddress('admin-noreply')
					]);
					$this->mailer->send($message);
				} catch (\Exception $e) {
					$noMail[] = $uid;
				}
			}
		}
		$progress->finish();
		if (empty($noMail)) {
			$this->output->writeln("\n\nPassword successfully send to all users");
		} else {
			$table = new Table($this->output);
			$table->setHeaders(array('Username', 'Private key password'));
			$this->output->writeln("\n\nCould not send password to following users:\n");
			$rows = [];
			foreach ($noMail as $uid) {
				$rows[] = [$uid, $this->userPasswords[$uid]];
			}
			$table->setRows($rows);
			$table->render();
		}
	}
protected function sendPasswordsByMail ( ) { $ noMail = [ ] ; $ this -> output -> writeln ( '' ) ; $ progress = new ProgressBar ( $ this -> output , count ( $ this -> userPasswords ) ) ; $ progress -> start ( ) ; foreach ( $ this -> userPasswords as $ uid => $ password ) { $ progress -> advance ( ) ; if ( ! empty ( $ password ) ) { $ recipient = $ this -> userManager -> get ( $ uid ) ; $ recipientDisplayName = $ recipient -> getDisplayName ( ) ; $ to = $ recipient -> getEMailAddress ( ) ; if ( $ to === '' ) { $ noMail [ ] = $ uid ; continue ; } $ subject = ( string ) $ this -> l -> t ( 'one-time password for server-side-encryption' ) ; list ( $ htmlBody , $ textBody ) = $ this -> createMailBody ( $ password ) ; try { $ message = $ this -> mailer -> createMessage ( ) ; $ message -> setSubject ( $ subject ) ; $ message -> setTo ( [ $ to => $ recipientDisplayName ] ) ; $ message -> setHtmlBody ( $ htmlBody ) ; $ message -> setPlainBody ( $ textBody ) ; $ message -> setFrom ( [ \ OCP \ Util :: getDefaultEmailAddress ( 'admin-noreply' ) ] ) ; $ this -> mailer -> send ( $ message ) ; } catch ( \ Exception $ e ) { $ noMail [ ] = $ uid ; } } } $ progress -> finish ( ) ; if ( empty ( $ noMail ) ) { $ this -> output -> writeln ( " \n \n Password successfully send to all users " ) ; } else { $ table = new Table ( $ this -> output ) ; $ table -> setHeaders ( array ( 'Username' , 'Private key password' ) ) ; $ this -> output -> writeln ( " \n \n Could not send password to following users: \n " ) ; $ rows = [ ] ; foreach ( $ noMail as $ uid ) { $ rows [ ] = [ $ uid , $ this -> userPasswords [ $ uid ] ] ; } $ table -> setRows ( $ rows ) ; $ table -> render ( ) ; } }
send encryption key passwords to the users by mail
send encryption key passwords to the users by mail
// send it out now