Skip to content

nattreid/mailing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailing pro Nette Framework

Nastavení v config.neon

extensions:
    - NAttreid\Mailing\DI\MailingExtension

mailing:
    sender: 'sender <[email protected]>'
    variables: # v latte mailu promenne
        title: 'Test.cz' 
        supportEmail: '[email protected]' 
    mailer: 
        - App/Mailer
        - App/Mailer2('sender2 <[email protected]>')

Použití

Vytvořte třídu děděním z \NAttreid\Mailing\BaseMailer

class Mailer extends \NAttreid\Mailing\BaseMailer {

    /**
     * Odeslani linku pro zmenu hesla
     * @param string $email
     * @param string $hash
     */
    public function sendRestorePassword($email, $hash) {
        $mail = $this->createMail('template');
        // nebo
        $mail = $this->createMailFromString('<body><p>sablona jako string</p></body>);

        $mail->link = $this->link('someLink', [
            'hash' => $hash
        ]);

        $mail->setSubject('translateMessage')
                ->addTo($email);

        $mail->send();
    }

Odeslání

/** @var \App\Services\Mailer @inject */
public $mailer;

$this->mailer->sendRestorePassword($email, $hash);