×ðÁú¿­Ê±

ThinkPHP6ÖÐÔõÑù¾ÙÐÐÓʼþ·¢ËͲÙ×÷£¿

½üÄêÀ´ £¬Óʼþ×÷ΪһÖÖ×îΪ³£¼ûµÄͨѶ·½·¨ £¬±»ÆÕ±éÓ¦ÓÃÓÚÖÖÖÖÓ¦Óó¡¾°ÖС£ÔÚ²î±ðµÄwebÓ¦ÓÃÖÐ £¬Ò²¾­³£ÐèҪͨ¹ý·¢ËÍÓʼþµÄ·½·¨À´¾ÙÐÐ֪ͨ¡¢ÑéÖ¤µÈ¹¦Ð§¡£¶øÔÚʹÓÃthinkphp6¿ò¼Ü¿ª·¢webÓ¦ÓõÄÀú³ÌÖÐ £¬ÎÒÃÇÐèÒªÏàʶÔõÑù¾ÙÐÐÓʼþ·¢ËͲÙ×÷ £¬ÒÔ±ã¸üºÃµØʵÏÖÖÖÖÖ¹¦Ð§¡£ÏÂÃæÎÒÃǽ«ÏÈÈÝÔõÑùÔÚthinkphp6ÖоÙÐÐÓʼþ·¢ËͲÙ×÷¡£

ÉèÖÃÓʼþ

ÔÚThinkPHP6ÖÐÉèÖÃÓʼþºÜÊÇÀû±ã¡£Ö»ÐèÒªÔÚÏîÄ¿¸ùĿ¼ÏµÄ.envÎļþÖмÓÈëÈçÏ´úÂë¼´¿É£º

MAIL_DRIVER=smtp
MAIL_HOST=smtp.qq.com
MAIL_PORT=465
MAIL_USERNAME=xxx@qq.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=xxx@qq.com
MAIL_FROM_NAME=xxx

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖÐ £¬ÆäÖÐMAIL_DRIVERÖ¸¶¨ÁËʹÓõÄÇý¶¯ £¬ÕâÀïÎÒÃÇʹÓÃsmtp£»MAIL_HOSTÖ¸¶¨ÁËÓʼþЧÀÍÆ÷µÄµØµã £¬ÕâÀïÎÒÃÇʹÓõÄÊÇQQÆóÒµÓÊÏäµÄµØµã£»MAIL_PORTÖ¸¶¨Á˶˿ںÅ £¬ÕâÀïÎÒÃÇʹÓÃ465¶Ë¿Ú£»MAIL_USERNAMEÖ¸¶¨ÁË·¢¼þÈËÓÊÏäµÄÕ˺Å£»MAIL_PASSWORDÖ¸¶¨ÁË·¢¼þÈËÓÊÏäµÄÃÜÂ룻MAIL_ENCRYPTIONÖ¸¶¨ÁËÓʼþ¼ÓÃÜ·½·¨ £¬ÕâÀïÎÒÃÇʹÓÃÁËSSL¼ÓÃÜ·½·¨£»MAIL_FROM_ADDRESSÖ¸¶¨ÁË·¢¼þÈËÓÊÏäµØµã£»MAIL_FROM_NAMEÖ¸¶¨ÁË·¢¼þÈËÐÕÃû¡£

·¢ËÍÓʼþ

ÉèÖúÃÓʼþÖ®ºó £¬ÎÒÃǾͿÉÒÔ×îÏÈ·¢ËÍÓʼþÁË¡£Ê¹ÓÃThinkPHP6ÌṩµÄÓʼþÀàMail £¬¿ÉÒÔºÜÊÇÀû±ãµØʵÏÖÓʼþ·¢ËͲÙ×÷¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄÓʼþ·¢ËÍʾÀý£º

use thinkacadeMail;

Mail::to('xxx@qq.com')->subject('²âÊÔÓʼþ')->html('<h1>ÕâÊÇÒ»·â²âÊÔÓʼþ</h1>');

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖÐ £¬ÎÒÃÇʹÓÃÁËMailÀàµÄto¡¢subject¡¢htmlÒªÁì¡£ÆäÖÐtoÒªÁìÖ¸¶¨ÁËÊÕ¼þÈËÓÊÏäµØµã£»subjectÒªÁìÖ¸¶¨ÁËÓʼþÖ÷Ì⣻htmlÒªÁìÖ¸¶¨ÁËÓʼþÕýÎÄÄÚÈÝ £¬²¢¿ÉÒÔʹÓÃHTMLÃûÌá£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

×¢ÖØ£ºÔÚ¾ÙÐÐÓʼþ·¢ËͲÙ×÷֮ǰ £¬ÎÒÃÇÐèҪȷ±£ÒѾ­×°ÖÃÁËPHPMailerÀà¿â¡£Äã¿ÉÒÔʹÓÃComposer¾ÙÐÐ×°Öà £¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

composer require phpmailer/phpmailer

µÇ¼ºó¸´ÖÆ

×Ô½ç˵ÓʼþÉèÖÃ

ÔÚÉÏÊöʾÀýÖÐ £¬ÎÒÃÇͨ¹ýÔÚ.envÎļþÖоÙÐÐÉèÖÃÀ´ÊµÏÖÓʼþ·¢Ë͹¦Ð§¡£µ«ÓÐʱ¼ä £¬ÎÒÃÇ¿ÉÄÜÐèÒªÔÚ´úÂëÖÐƾ֤³¡¾°¶¯Ì¬¸ü¸ÄÓʼþÉèÖᣴËʱ £¬ÎÒÃÇ¿ÉÒÔʹÓÃConfigÀàÀ´ÊµÏÖ £¬¿ÉÒÔͨ¹ýÒÔÏ´úÂë¾ÙÐÐ×Ô½ç˵ÉèÖãº

use thinkacadeConfig;
use thinkacadeMail;

$config = [
    'smtp_host' => 'smtp.qq.com',
    'smtp_port' => '465',
    'smtp_user' => 'xxx@qq.com',
    'smtp_pass' => 'xxx',
    'smtp_secure' => 'ssl'
];

Config::set('mail', $config);
Mail::to('xxx@qq.com')->subject('²âÊÔÓʼþ')->html('<h1>ÕâÊÇÒ»·â²âÊÔÓʼþ</h1>');

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖÐ £¬ÎÒÃÇʹÓÃConfigÀàµÄsetÒªÁìÀ´¾ÙÐÐÓʼþÉèÖÃÉèÖà £¬È»ºóÔÙʹÓÃMailÀàÀ´¾ÙÐÐÓʼþ·¢ËͲÙ×÷¡£ÕâÑù £¬ÎÒÃǾͿÉÒÔƾ֤×Ô¼ºµÄÐèÇó¾ÙÐÐÓʼþÉèÖÃÁË¡£

×ܽá

±¾ÎÄÏÈÈÝÁËÔÚThinkPHP6ÖоÙÐÐÓʼþ·¢ËͲÙ×÷µÄÏà¹ØÄÚÈÝ¡£Ö»Ðè¼òÆÓµÄÉèÖÃÒ»ÏÂÓʼþ²ÎÊý £¬È»ºóŲÓÃMailÀ༴¿É¿ìËÙµÄʵÏÖÓʼþ·¢Ë͹¦Ð§¡£ÔÚÏÖʵʹÓÃÖÐ £¬ÎÒÃÇ¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóÀ´¾ÙÐÐ×Ô½ç˵ÉèÖà £¬ÒÔÈ·±£Óʼþ·¢Ë͹¦Ð§¿ÉÒÔÔ½·¢ÎÞа¡¢¸ßЧµØÍê³É¡£

ÒÔÉϾÍÊÇThinkPHP6ÖÐÔõÑù¾ÙÐÐÓʼþ·¢ËͲÙ×÷£¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿