Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config/goalioforgotpassword.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ $settings = array(
*/
//'validate_existing_record' => true


/**
* Email format
* Valid: html or text
*/
//'email_format' => 'text'

/**
* End of GoalioForgotPassword configuration
*/
Expand Down
2 changes: 2 additions & 0 deletions src/GoalioForgotPassword/Options/ForgotOptionsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public function setResetEmailSubjectLine($subject);
public function getResetEmailSubjectLine();
public function setResetEmailTemplate($template);
public function getResetEmailTemplate();
public function setEmailFormat($emailFormat);
public function getEmailFormat();
}
21 changes: 21 additions & 0 deletions src/GoalioForgotPassword/Options/ModuleOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class ModuleOptions extends AbstractOptions implements
* @var int
*/
protected $resetExpire = 86400;

/**
* @var string
*/
protected $emailFormat = 'text';

/**
* @var bool
Expand Down Expand Up @@ -118,4 +123,20 @@ public function setResetExpire($resetExpire) {
public function getResetExpire() {
return $this->resetExpire;
}

/**
* @return string
*/
public function getEmailFormat() {
return $this->emailFormat;
}

/**
* @param string $emailFormat
* @return $this
*/
public function setEmailFormat($emailFormat) {
$this->emailFormat = $emailFormat;
return $this;
}
}
12 changes: 11 additions & 1 deletion src/GoalioForgotPassword/Service/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace GoalioForgotPassword\Service;

use GoalioMailService\Mail\Service\Message;
use Zend\Mail\Transport\TransportInterface;

use ZfcUser\Options\PasswordOptionsInterface;
Expand Down Expand Up @@ -77,13 +78,22 @@ public function sendProcessForgotRequest($userId, $email)

public function sendForgotEmailMessage($to, $model)
{
/** @var Message $mailService */
$mailService = $this->getServiceManager()->get('goaliomailservice_message');

$from = $this->getOptions()->getEmailFromAddress();
$subject = $this->getOptions()->getResetEmailSubjectLine();
$template = $this->getOptions()->getResetEmailTemplate();

$message = $mailService->createTextMessage($from, $to, $subject, $template, array('record' => $model));
switch($this->getOptions()->getEmailFormat()) {
case "html":
$message = $mailService->createHtmlMessage($from, $to, $subject, $template, array('record' => $model));
break;
case "text":
default:
$message = $mailService->createTextMessage($from, $to, $subject, $template, array('record' => $model));
break;
}

$mailService->send($message);
}
Expand Down