Problem with Swiftmailer

Emails are not sent with ->setFrom(‘webmaster@example.com’)

i have:


'mailer' => [

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

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

            'useFileTransport' => false,

        ],


  public function sendEmail($email)

    {

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

                ['html' => 'contact-html', 'text' => 'contact-text'],

                ['model' => $this]

            )

            ->setFrom('webmaster@example.com')

            ->setTo($email)

            ->setSubject($this->subject)

            ->setTextBody($this->body)

            ->send();

    }



if i delete row ->setFrom(‘webmaster@example.com’) all works good.

What is that?

May be your server has no permission to send mails from domain "example.com" ?

I think that for production usage it’s better to use SMTP:

http://www.yiiframework.com/wiki/656/how-to-send-emails-using-smtp/

function mail() works good, and i tried any emails, how can i detect access?