apps/sharebymail/lib/ShareByMailProvider.php
/**
	 * send password to recipient of a mail share
	 *
	 * @param IShare $share
	 * @param string $password
	 * @return bool
	 */
send password to recipient of a mail share
@param IShare $share
@param string $password
@return bool
send password to recipient of a mail share @param IShare $share @param string $password @return bool
protected function sendPassword(IShare $share, $password) {
		$filename = $share->getNode()->getName();
		$initiator = $share->getSharedBy();
		$shareWith = $share->getSharedWith();
		if ($password === '' || $this->settingsManager->sendPasswordByMail() === false) {
			return false;
		}
		$initiatorUser = $this->userManager->get($initiator);
		$initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator;
		$initiatorEmailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
		$subject = (string)$this->l->t('Password to access »%s« shared to you by %s', [$filename, $initiatorDisplayName]);
		$plainBodyPart = $this->l->t("%s shared »%s« with you.\nYou should have already received a separate mail with a link to access it.\n", [$initiatorDisplayName, $filename]);
		$htmlBodyPart = $this->l->t('%s shared »%s« with you. You should have already received a separate mail with a link to access it.', [$initiatorDisplayName, $filename]);
		$message = $this->mailer->createMessage();
		$emailTemplate = $this->mailer->createEMailTemplate();
		$emailTemplate->addHeader();
		$emailTemplate->addHeading($this->l->t('Password to access »%s«', [$filename]), false);
		$emailTemplate->addBodyText($htmlBodyPart, $plainBodyPart);
		$emailTemplate->addBodyText($this->l->t('It is protected with the following password: %s', [$password]));
		$emailTemplate->addFooter();
		if ($initiatorEmailAddress !== null) {
			$message->setFrom([$initiatorEmailAddress => $initiatorDisplayName]);
		}
		$message->setTo([$shareWith]);
		$message->setSubject($subject);
		$message->setBody($emailTemplate->renderText(), 'text/plain');
		$message->setHtmlBody($emailTemplate->renderHtml());
		$this->mailer->send($message);
		$this->createPasswordSendActivity($share, $shareWith, false);
		return true;
	}
protected function sendPassword ( IShare $ share , $ password ) { $ filename = $ share -> getNode ( ) -> getName ( ) ; $ initiator = $ share -> getSharedBy ( ) ; $ shareWith = $ share -> getSharedWith ( ) ; if ( $ password === '' || $ this -> settingsManager -> sendPasswordByMail ( ) === false ) { return false ; } $ initiatorUser = $ this -> userManager -> get ( $ initiator ) ; $ initiatorDisplayName = ( $ initiatorUser instanceof IUser ) ? $ initiatorUser -> getDisplayName ( ) : $ initiator ; $ initiatorEmailAddress = ( $ initiatorUser instanceof IUser ) ? $ initiatorUser -> getEMailAddress ( ) : null ; $ subject = ( string ) $ this -> l -> t ( 'Password to access »%s« shared to you by %s',  [ f i lename,  $ n itiatorDisplayName]) ; $ plainBodyPart = $ this -> l -> t ( " %s shared »%s« with you.\n Yo u should have already received a separate mail with a link to access it.\n ", [ i n itiatorDisplayName,  $ i lename]) ; $ htmlBodyPart = $ this -> l -> t ( '%s shared »%s« with you. You should have already received a separate mail with a link to access it.',  [ i n itiatorDisplayName,  $ i lename]) ; $ 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 ( $ htmlBodyPart , $ plainBodyPart ) ; $ emailTemplate -> addBodyText ( $ this -> l -> t ( 'It is protected with the following password: %s' , [ $ password ] ) ) ; $ emailTemplate -> addFooter ( ) ; if ( $ initiatorEmailAddress !== null ) { $ message -> setFrom ( [ $ initiatorEmailAddress => $ initiatorDisplayName ] ) ; } $ message -> setTo ( [ $ shareWith ] ) ; $ message -> setSubject ( $ subject ) ; $ message -> setBody ( $ emailTemplate -> renderText ( ) , 'text/plain' ) ; $ message -> setHtmlBody ( $ emailTemplate -> renderHtml ( ) ) ; $ this -> mailer -> send ( $ message ) ; $ this -> createPasswordSendActivity ( $ share , $ shareWith , false ) ; return true ; }
send password to recipient of a mail share
 @param IShare $share
 @param string $password
 @return bool
send password to recipient of a mail share @param IShare $share @param string $password @return bool