Yii2 Send mail (configure QQ version)

Source: Internet
Author: User
Tags server port yii

1. Configure in config file

' Mailer ' => [  
           ' class ' => ' Yii\swiftmailer\mailer ',//server class
            ' Usefiletransport ' =>false,//must have, false send mail, true just generate messages under Runtime folder, do not send mail </span>	   
           ' transport ' => [  
              ' class ' => ' Swift_smtptransport ',//Use of Classes
              ' host ' => ' smtp.qq.com ',//mailbox Service one address
              ' username ' => ' 1806001025@qq.com ',//email address, send email  
              ' password ' => ' *********** ',  //fill in the Mailbox password
              ' port ' => ' 465  '. Server Port
              ' encryption ' => ' SSL ',//encryption mode 
			  ],
		' messageconfig ' =>[' charset ' => ' UTF-8 '  
                 ,//code 
                 ' from ' =>[' 1806001025@qq.com ' => ' admin '  ///e-mail address and name displayed in message
                ],  
 

The above configuration, according to your mailbox, to configure. 2: Inside the controller or inside the model you can call the

        $FFF = Yii:: $app->mailer->compose ()
		        ->setfrom ([' 1806001025@qq.com ' => ' I see you are stupid '])//and corresponds to the From field above  can write only one
                        ->setto (' 429281869@qq.com ')
                       ->setsubject (' dsfsfsddddddddddddddddddddddddddd ')
                       - >settextbody (' sdfffffffffffffffffffffffffffff ')
                       ->send ();

3: If the QQ mailbox Open POP3/SMTP Service

QQ Mailbox-> Set-"account"





4: After sending the message, is this appearance, pay attention to the above settings, you know how to get it.


It is believed that you will understand it. Haha, come on together .


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.