apps/sharebymail/lib/ShareByMailProvider.php
/**
	 * send auto generated password to the owner. This happens if the admin enforces
	 * a password for mail shares and forbid to send the password by mail to the recipient
	 *
	 * @param IShare $share
	 * @param string $password
	 * @return bool
	 * @throws \Exception
	 */
send auto generated password to the owner. This happens if the admin enforces
a password for mail shares and forbid to send the password by mail to the recipient

@param IShare $share
@param string $password
@return bool
@throws \Exception
send auto generated password to the owner . This happens if the admin enforces a password for mail shares and forbid to send the password by mail to the recipient @param IShare $share @param string $password @return bool @throws \ Exception
protected function sendPasswordToOwner(IShare $share, $password) {
		$filename = $share->getNode()->getName();
		$initiator = $this->userManager->get($share->getSharedBy());
		$initiatorEMailAddress = ($initiator instanceof IUser) ? $initiator->getEMailAddress() : null;
		$initiatorDisplayName = ($initiator instanceof IUser) ? $initiator->getDisplayName() : $share->getSharedBy();
		$shareWith = $share->getSharedWith();
		if ($initiatorEMailAddress === null) {
			throw new \Exception(
				$this->l->t("We can't send you the auto-generated password. Please set a valid email address in your personal settings and try again.")
			);
		}
		$subject = (string)$this->l->t('Password to access »%s« shared with %s', [$filename, $shareWith]);
		$bodyPart = $this->l->t("You just shared »%s« with %s. The share was already send to the recipient. Due to the security policies defined by the administrator of %s each share needs to be protected by password and it is not allowed to send the password directly to the recipient. Therefore you need to forward the password manually to the recipient.", [$filename, $shareWith, $this->defaults->getName()]);
		$message = $this->mailer->createMessage();
		$emailTemplate = $this->mailer->createEMailTemplate();
		$emailTemplate->addHeader();
		$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
		$emailTemplate->addBodyText($bodyPart);
		$emailTemplate->addBodyText($this->l->t('This is the password: %s', [$password]));
		$emailTemplate->addBodyText($this->l->t('You can choose a different password at any time in the share dialog.'));
		$emailTemplate->addFooter();
		if ($initiatorEMailAddress) {
			$message->setFrom([$initiatorEMailAddress => $initiatorDisplayName]);
		}
		$message->setTo([$initiatorEMailAddress => $initiatorDisplayName]);
		$message->setSubject($subject);
		$message->setBody($emailTemplate->renderText(), 'text/plain');
		$message->setHtmlBody($emailTemplate->renderHtml());
		$this->mailer->send($message);
		$this->createPasswordSendActivity($share, $shareWith, true);
		return true;
	}
protected function sendPasswordToOwner ( IShare $ share , $ password ) { $ filename = $ share -> getNode ( ) -> getName ( ) ; $ initiator = $ this -> userManager -> get ( $ share -> getSharedBy ( ) ) ; $ initiatorEMailAddress = ( $ initiator instanceof IUser ) ? $ initiator -> getEMailAddress ( ) : null ; $ initiatorDisplayName = ( $ initiator instanceof IUser ) ? $ initiator -> getDisplayName ( ) : $ share -> getSharedBy ( ) ; $ shareWith = $ share -> getSharedWith ( ) ; if ( $ initiatorEMailAddress === null ) { throw new \ Exception ( $ this -> l -> t ( " We can't send you the auto-generated password. Please set a valid email address in your personal settings and try again. " ) ) ; } $ subject = ( string ) $ this -> l -> t ( 'Password to access »%s« shared with %s',  [ f i lename,  $ h areWith]) ; $ bodyPart = $ this -> l -> t ( " You just shared »%s« with %s. The share was already send to the recipient. Due to the security policies defined by the administrator of %s each share needs to be protected by password and it is not allowed to send the password directly to the recipient. Therefore you need to forward the password manually to the recipient.", [ f i lename,  $ h areWith,  $ h is-> de faults-> ge tName() ] ) ; $ message = $ this -> mailer -> createMessage ( ) ; $ emailTemplate = $ this -> mailer -> createEMailTemplate ( ) ; $ emailTemplate -> addHeader ( ) ; $ emailTemplate -> addHeading ( $ this -> l -> t ( 'Password to access »%s«',  [ f i lename]) , f lse); $ emailTemplate -> addBodyText ( $ bodyPart ) ; $ emailTemplate -> addBodyText ( $ this -> l -> t ( 'This is the password: %s' , [ $ password ] ) ) ; $ emailTemplate -> addBodyText ( $ this -> l -> t ( 'You can choose a different password at any time in the share dialog.' ) ) ; $ emailTemplate -> addFooter ( ) ; if ( $ initiatorEMailAddress ) { $ message -> setFrom ( [ $ initiatorEMailAddress => $ initiatorDisplayName ] ) ; } $ message -> setTo ( [ $ initiatorEMailAddress => $ initiatorDisplayName ] ) ; $ message -> setSubject ( $ subject ) ; $ message -> setBody ( $ emailTemplate -> renderText ( ) , 'text/plain' ) ; $ message -> setHtmlBody ( $ emailTemplate -> renderHtml ( ) ) ; $ this -> mailer -> send ( $ message ) ; $ this -> createPasswordSendActivity ( $ share , $ shareWith , true ) ; return true ; }
send auto generated password to the owner.
send auto generated password to the owner .