-1

I want to send email from my application, but my host want extra money for smtp protocol Is there a way to send email by swiftmailer in yii2 wit pop3 protocol?

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
Behzad Hassani
  • 2,129
  • 4
  • 30
  • 51

2 Answers2

2

For sending email via Yii2 You can follow the below procedure.

main.php

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


            'viewPath' => '@app/mail',
            'useFileTransport' => false,//set this property to false to send mails to real email addresses
             //comment the following array to send mail using php's mail function
            'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'email id',
            'password' => 'password',
            'port' => '587',
            'encryption' => 'tls',
            ],

            ],

Controller

\Yii::$app->mail->compose('your_view', ['params' => $params])
    ->setFrom([\Yii::$app->params['supportEmail'] => 'Test Mail'])
    ->setTo('to_email@xyz.com')
    ->setSubject('This is a test mail ' )
    ->send();

For more details please refer Docs

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
Bloodhound
  • 2,906
  • 11
  • 37
  • 71
-1

The pop3 protocol is only for getting mail from server is not for send mail !

But for sending mail you can use the default php mail function

You can read more on the following :

function.mail.php

GAMITG
  • 3,810
  • 7
  • 32
  • 51
Amir Mohsen
  • 853
  • 2
  • 9
  • 23