lundi 5 mars 2018

Send New User password to emails - Laravel, Jobs, Mail

when new user is created by X role an email is sent to the newly created user with a random password generator.

I am trying to pass the password as an object and I also tried sending it as a string but unable to send it by email. I get an error and mail job fails in this line.

// I am sure this is the line with error because the mail is sent successfully when removed
You Pswd :   

Controller

$pswdGen = Helpers::generateRandomString();
...
$pass['pass'] = $pswdString; // an Object
$this->dispatch(new NewParticipantEmail(.., .., $pass));

Jobs

protected $password;

/**
 * Create a new job instance.
 *
 * @return void
 */
public function __construct(.., .., $passwordString)
{
    $this->password = $passwordString;
}

public function handle(Mailer $mailer) {

    $participant = $this->user;
    $senderEmail = $this->sender;
    $pswd = $this->password;

    $mailer->send('email.template', [..., 'pswd' => $pswd], function ($message) use ($param1, $param2) {

    ....

    });
}

blade

Your Pswd : 



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2H5WLAY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire