How i can change the sender using swiftmailer


I have the following configuration for mail:

'class' => 'yii\swiftmailer\Mailer',

	'viewPath' => '@common/mail',

	'useFileTransport' => false, //for the testing purpose, you need to enable this

	'transport' => [

    	'class' => 'Swift_SmtpTransport',

    	'host' => '',

    	'username' => ',

    	'password' => 'the password',

    	'port' => '587', // Port 25 is a very common port too

    	'encryption' => 'tls', // It is often used, check your provider or mail server specs


And in params.php I have the following:


return [

'adminEmail' => ',

	// caducidad del token de renovación de la contraseña.

	'user.passwordResetTokenExpire' => 3600,


The email sender works ok on registering and reseting passwords but in contact form, which the sender (email from) is the email set in the form, is the same username in mail config what is too strange because the code is just like was made by the app-advanced template:

public function sendEmail($email) {

    	return Yii::$app->mailer->compose()


                    	->setFrom([$this->email => $this->name])





The setFrom method is supposed to add the name and email sender. the setTo works because the emails arrives to adminEmail inbox, but as I say, the setFrom method is not accomplishing its purpose.

Then my question is to know if is a bug, a mistake…