src/Model/Table/FeedbackstoreTable.php
public function mail(array $feedbackObject, $copyreporter = false) {
		$returnobject = [];
		$returnobject['result'] = false;
		$returnobject['msg'] = '';

		if (empty($feedbackObject)) {
			return $returnobject;
		}

		//Read settings from config if not in copy mode
		$to = Configure::read('Feedback.methods.mail.to');
		$from = Configure::read('Feedback.methods.mail.from');

		// Change recipient if sending a copy
		if ($copyreporter) {
			$to = $feedbackObject['email'];
		}

		//Change the sender if any given
		if (!empty($feedbackObject['email']) && !empty($feedbackObject['name'])) {
			$from = [$feedbackObject['email'] => $feedbackObject['name']];
		}

		//Tmp store the screenshot:
		$tmpfile = APP . 'tmp' . DS . time() . '_' . rand(1000, 9999) . '.png';
		if (!file_put_contents($tmpfile, base64_decode($feedbackObject['screenshot']))) {
			//Need to save tmp file
			throw new NotFoundException('Could not save tmp file for attachment in mail');
		}

		$email = new Email();
		$email->from($from);
		$email->to($to);
		$email->subject($feedbackObject['subject']);
		$email->emailFormat('html');
		$email->attachments([
		    'screenshot.png' => [
		        'file' => $tmpfile,
		        'mimetype' => 'image/png',
		        'contentId' => 'id-screenshot'
		    ]
		]);

		//Mail specific: append browser, browser version, URL, etc to feedback :
		if ($copyreporter) {
			$feedbackObject['feedback'] = '<p>' . __d('feedback', 'A copy of your submitted feedback:') . '</p>' . $feedbackObject['feedback'];
		}
		$feedbackObject['feedback'] .= '<p>';
		$feedbackObject['feedback'] .= sprintf('Browser: %s %s<br/>', $feedbackObject['browser'], $feedbackObject['browser_version']);
		$feedbackObject['feedback'] .= sprintf('Url: %s<br/>', $feedbackObject['url']);
		$feedbackObject['feedback'] .= sprintf('OS: %s<br/>', $feedbackObject['os']);
		$feedbackObject['feedback'] .= sprintf('By: %s<br/>', $feedbackObject['name']);
		$feedbackObject['feedback'] .= 'Screenshot: <br/>';
		$feedbackObject['feedback'] .= '</p>';
		$feedbackObject['feedback'] .= '<img src="cid:id-screenshot">'; //Add inline screenshot

		if ($email->send($feedbackObject['feedback'])) {
			$returnobject['result'] = true;
			$returnobject['msg'] = __d('feedback', 'Thank you. Your feedback was saved.');

			return $returnobject;
		}

		unlink($tmpfile);

		return $returnobject;
	}
public function mail(array $feedbackObject, $copyreporter = false) {
		$returnobject = [];
		$returnobject['result'] = false;
		$returnobject['msg'] = '';

		if (empty($feedbackObject)) {
			return $returnobject;
		}

		//Read settings from config if not in copy mode
		$to = Configure::read('Feedback.methods.mail.to');
		$from = Configure::read('Feedback.methods.mail.from');

		// Change recipient if sending a copy
		if ($copyreporter) {
			$to = $feedbackObject['email'];
		}

		//Change the sender if any given
		if (!empty($feedbackObject['email']) && !empty($feedbackObject['name'])) {
			$from = [$feedbackObject['email'] => $feedbackObject['name']];
		}

		//Tmp store the screenshot:
		$tmpfile = APP . 'tmp' . DS . time() . '_' . rand(1000, 9999) . '.png';
		if (!file_put_contents($tmpfile, base64_decode($feedbackObject['screenshot']))) {
			//Need to save tmp file
			throw new NotFoundException('Could not save tmp file for attachment in mail');
		}

		$email = new Email();
		$email->from($from);
		$email->to($to);
		$email->subject($feedbackObject['subject']);
		$email->emailFormat('html');
		$email->attachments([
		    'screenshot.png' => [
		        'file' => $tmpfile,
		        'mimetype' => 'image/png',
		        'contentId' => 'id-screenshot'
		    ]
		]);

		//Mail specific: append browser, browser version, URL, etc to feedback :
		if ($copyreporter) {
			$feedbackObject['feedback'] = '<p>' . __d('feedback', 'A copy of your submitted feedback:') . '</p>' . $feedbackObject['feedback'];
		}
		$feedbackObject['feedback'] .= '<p>';
		$feedbackObject['feedback'] .= sprintf('Browser: %s %s<br/>', $feedbackObject['browser'], $feedbackObject['browser_version']);
		$feedbackObject['feedback'] .= sprintf('Url: %s<br/>', $feedbackObject['url']);
		$feedbackObject['feedback'] .= sprintf('OS: %s<br/>', $feedbackObject['os']);
		$feedbackObject['feedback'] .= sprintf('By: %s<br/>', $feedbackObject['name']);
		$feedbackObject['feedback'] .= 'Screenshot: <br/>';
		$feedbackObject['feedback'] .= '</p>';
		$feedbackObject['feedback'] .= '<img src="cid:id-screenshot">'; //Add inline screenshot

		if ($email->send($feedbackObject['feedback'])) {
			$returnobject['result'] = true;
			$returnobject['msg'] = __d('feedback', 'Thank you. Your feedback was saved.');

			return $returnobject;
		}

		unlink($tmpfile);

		return $returnobject;
	}
public function mail ( array $ feedbackObject , $ copyreporter = false ) { $ returnobject = [ ] ; $ returnobject [ 'result' ] = false ; $ returnobject [ 'msg' ] = '' ; if ( empty ( $ feedbackObject ) ) { return $ returnobject ; } //Read settings from config if not in copy mode $ to = Configure :: read ( 'Feedback.methods.mail.to' ) ; $ from = Configure :: read ( 'Feedback.methods.mail.from' ) ; // Change recipient if sending a copy if ( $ copyreporter ) { $ to = $ feedbackObject [ 'email' ] ; } //Change the sender if any given if ( ! empty ( $ feedbackObject [ 'email' ] ) && ! empty ( $ feedbackObject [ 'name' ] ) ) { $ from = [ $ feedbackObject [ 'email' ] => $ feedbackObject [ 'name' ] ] ; } //Tmp store the screenshot: $ tmpfile = APP . 'tmp' . DS . time ( ) . '_' . rand ( 1000 , 9999 ) . '.png' ; if ( ! file_put_contents ( $ tmpfile , base64_decode ( $ feedbackObject [ 'screenshot' ] ) ) ) { //Need to save tmp file throw new NotFoundException ( 'Could not save tmp file for attachment in mail' ) ; } $ email = new Email ( ) ; $ email -> from ( $ from ) ; $ email -> to ( $ to ) ; $ email -> subject ( $ feedbackObject [ 'subject' ] ) ; $ email -> emailFormat ( 'html' ) ; $ email -> attachments ( [ 'screenshot.png' => [ 'file' => $ tmpfile , 'mimetype' => 'image/png' , 'contentId' => 'id-screenshot' ] ] ) ; //Mail specific: append browser, browser version, URL, etc to feedback : if ( $ copyreporter ) { $ feedbackObject [ 'feedback' ] = '<p>' . __d ( 'feedback' , 'A copy of your submitted feedback:' ) . '</p>' . $ feedbackObject [ 'feedback' ] ; } $ feedbackObject [ 'feedback' ] .= '<p>' ; $ feedbackObject [ 'feedback' ] .= sprintf ( 'Browser: %s %s<br/>' , $ feedbackObject [ 'browser' ] , $ feedbackObject [ 'browser_version' ] ) ; $ feedbackObject [ 'feedback' ] .= sprintf ( 'Url: %s<br/>' , $ feedbackObject [ 'url' ] ) ; $ feedbackObject [ 'feedback' ] .= sprintf ( 'OS: %s<br/>' , $ feedbackObject [ 'os' ] ) ; $ feedbackObject [ 'feedback' ] .= sprintf ( 'By: %s<br/>' , $ feedbackObject [ 'name' ] ) ; $ feedbackObject [ 'feedback' ] .= 'Screenshot: <br/>' ; $ feedbackObject [ 'feedback' ] .= '</p>' ; $ feedbackObject [ 'feedback' ] .= '<img src="cid:id-screenshot">' ; //Add inline screenshot if ( $ email -> send ( $ feedbackObject [ 'feedback' ] ) ) { $ returnobject [ 'result' ] = true ; $ returnobject [ 'msg' ] = __d ( 'feedback' , 'Thank you. Your feedback was saved.' ) ; return $ returnobject ; } unlink ( $ tmpfile ) ; return $ returnobject ; }
Mail function
- Function has possibility to mail submitting user instead of target adress

@deprecated Make a Store class

@param array $feedbackObject
@param bool $copyreporter
@return array
Mail function - Function has possibility to mail submitting user instead of target adress