Pawan lakhera
Pawan lakhera

Reputation: 197

Sending Email using Outlook MailServer in Yii

I am trying to send emails using outlook mail server in my yii website. I have used the below configuration :

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.office365.com',
                'username' => 'username',
                'password' => 'password', 
                'port' => '587',
                'encryption' => 'tls', 
                'streamOptions' => [
                        'ssl' => [
                          'verify_peer' => false,
                          'verify_peer_name' => false,
                          'allow_self_signed' => true
                         ],
                ],
            ],
                'useFileTransport' => false,
        ]

Previously I was using pair server configuration instead of outlook and mail was sending properly. But when I replaced pairserver with outlook it stopped working. Can any one please tell if anything I am missing.

Upvotes: 0

Views: 110

Answers (1)

rastik
rastik

Reputation: 2576

You need to make sure all of these conditions are met:

  • username is the full e-mail address of the user
  • this user has SMTP enabled - in Office 365 admin page open user details, select Mail tab and click Manage email apps - there you need to enable Authenticated SMTP.

Upvotes: 0

Related Questions