nineinchnick / yii2-usr

Yii framework module for user authentication, password reset, registration and profile updating. A port of yii-usr to Yii Framework 2.0.
http://demo2.niix.pl
MIT License
39 stars 8 forks source link

sendMail - Cannot send message without a sender address #19

Closed hamrak closed 10 years ago

hamrak commented 10 years ago

Swift_TransportException - Cannot send message without a sender address in .../vendor/nineinchnick/yii2-usr/controllers/UsrController.php – yii\mail\BaseMessage::send()

I have fixed it for my use as follows:

        $message = Yii::$app->mail->compose($mode, $params);
        $message->setFrom(isset(Yii::$app->params['noReplyEmail']) ? Yii::$app->params['noReplyEmail'] : 'no-reply@'.$_SERVER['HTTP_HOST']);
        $message->setTo([$model->getIdentity()->getEmail() => $model->getIdentity()->username]); 
...
nineinchnick commented 10 years ago

Thanks for reporting, I'll add a sender property to the Module.

nineinchnick commented 10 years ago

Oh wait, you can set the Mailer.messageConfig property in the app.

I'm going to put it in the readme.

hamrak commented 10 years ago

Can you put there a example for yii2? I'm using yii\swiftmailer\Mailer and it looks like there's no possibility of the sender set in Mailer configuration

nineinchnick commented 10 years ago

I updated the README file, check it out if it resolves the issue.