{"id":26039,"date":"2024-11-24T15:31:58","date_gmt":"2024-11-24T07:31:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26039\/"},"modified":"2024-11-24T15:31:58","modified_gmt":"2024-11-24T07:31:58","slug":"lithe-mail%ef%bc%9a%e7%ae%80%e5%8c%96-php-%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e4%b8%ad%e7%9a%84%e7%94%b5%e5%ad%90%e9%82%ae%e4%bb%b6%e5%8f%91%e9%80%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26039\/","title":{"rendered":"Lithe Mail\uff1a\u7b80\u5316 PHP \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u7535\u5b50\u90ae\u4ef6\u53d1\u9001"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173077992494003.jpg\" class=\"aligncenter\" title=\"Lithe Mail\uff1a\u7b80\u5316 PHP \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u7535\u5b50\u90ae\u4ef6\u53d1\u9001\u63d2\u56fe\" alt=\"Lithe Mail\uff1a\u7b80\u5316 PHP \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u7535\u5b50\u90ae\u4ef6\u53d1\u9001\u63d2\u56fe\" \/><\/p>\n<p>\u4f60\u597d\uff0c\u793e\u533a\uff01\u4eca\u5929\uff0c\u6211\u60f3\u5411\u60a8\u4ecb\u7ecd <strong>lithe ml<\/strong>\uff0c\u8fd9\u662f\u4e00\u4e2a\u7b80\u5316\u5728 php \u5e94\u7528\u7a0b\u5e8f\u4e2d\u901a\u8fc7 smtp \u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u7684\u8f6f\u4ef6\u5305\u3002\u5b83\u63d0\u4f9b\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u7075\u6d3b\u96c6\u6210\uff0c\u4f7f\u914d\u7f6e\u53d8\u5f97\u5bb9\u6613\u3002\u8ba9\u6211\u4eec\u770b\u770b\u5982\u4f55\u8bbe\u7f6e\u5e76\u5728\u60a8\u7684\u9879\u76ee\u4e2d\u4f7f\u7528\u5b83\u3002<\/p>\n<h2> \u5b89\u88c5 <\/h2>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7  \u5b89\u88c5\u8be5\u8f6f\u4ef6\u5305\u3002\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>composer require lithemod\/mail\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2> \u4f7f\u7528 <\/h2>\n<p>\u8fd9\u662f\u6709\u5173\u5982\u4f55\u4f7f\u7528\u8be5\u5305\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u7684\u7efc\u5408\u6307\u5357\uff1a<\/p>\n<h3> 1\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf <\/h3>\n<p>\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a .env \u6587\u4ef6\u5e76\u914d\u7f6e\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u8bbe\u7f6e\uff1a<\/p>\n<pre>mail_host=smtp.seuprovedor.com\nmail_port=587\nmail_username=seu-email@dominio.com\nmail_password=sua-senha\nmail_encryption=tls\nmail_from_address=noreply@dominio.com\nmail_from_name=seu nome ou empresa\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> 2. \u53d1\u9001\u7b80\u5355\u7684\u6587\u672c\u7535\u5b50\u90ae\u4ef6 <\/h3>\n<pre>&lt;?php\n\nrequire 'vendor\/autoload.php';\n\nuse lithesupportmail;\nuse lithesupportenv;\n\n\/\/ carregar vari\u00e1veis de ambiente\nenv::load(__dir__);\n\n\/\/ enviar o email\n$mail = mail::to('destinatario@dominio.com', 'nome do destinat\u00e1rio')\n    -&gt;subject('assunto do email')\n    -&gt;text('corpo do email em texto simples')\n    -&gt;send();\n\nif ($mail) {\n    echo 'email enviado com sucesso!';\n} else {\n    echo 'falha ao enviar o email.';\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> 3. \u53d1\u9001 html \u7535\u5b50\u90ae\u4ef6 <\/h3>\n<pre>&lt;?php\n\n$mail = mail::to('destinatario@dominio.com', 'nome do destinat\u00e1rio')\n    -&gt;subject('assunto do email')\n    -&gt;html('&lt;h1&gt;corpo do email em html&lt;\/h1&gt;')\n    -&gt;send();\n\nif ($mail) {\n    echo 'email enviado com sucesso!';\n} else {\n    echo 'falha ao enviar o email.';\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> 4. \u6dfb\u52a0\u6284\u9001\u548c\u5bc6\u4ef6\u6284\u9001\u6536\u4ef6\u4eba <\/h3>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u5c06\u6284\u9001\u548c\u5bc6\u4ef6\u6284\u9001\u6536\u4ef6\u4eba\u6dfb\u52a0\u5230\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u4e2d\uff1a<\/p>\n<h4> \u6dfb\u52a0\u6284\u9001 <\/h4>\n<pre>$mail = mail::to('destinatario@dominio.com', 'nome do destinat\u00e1rio')\n    -&gt;cc('cc@example.com', 'nome do cc')\n    -&gt;subject('assunto do email')\n    -&gt;text('corpo do email em texto simples')\n    -&gt;send();\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4> \u6dfb\u52a0\u5bc6\u4ef6\u6284\u9001 <\/h4>\n<pre>$mail = mail::to('destinatario@dominio.com', 'nome do destinat\u00e1rio')\n    -&gt;bcc('bcc@example.com', 'nome do bcc')\n    -&gt;subject('assunto do email')\n    -&gt;text('corpo do email em texto simples')\n    -&gt;send();\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> 5. \u5b9a\u4e49\u56de\u590d\u5730\u5740 <\/h3>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528replyto:<br \/>\u65b9\u6cd5\u8bbe\u7f6e\u56de\u590d\u5730\u5740 <\/p>\n<pre>$mail = mail::to('destinatario@dominio.com', 'nome do destinat\u00e1rio')\n    -&gt;replyto('replyto@example.com', 'nome da resposta')\n    -&gt;subject('assunto do email')\n    -&gt;text('corpo do email em texto simples')\n    -&gt;send();\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> 6. \u9644\u52a0\u6587\u4ef6 <\/h3>\n<p>\u8981\u5c06\u6587\u4ef6\u9644\u52a0\u5230\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\uff0c\u8bf7\u4f7f\u7528\u9644\u52a0\u65b9\u6cd5\uff1a<\/p>\n<pre>$mail = mail::to('destinatario@dominio.com', 'nome do destinat\u00e1rio')\n    -&gt;subject('assunto do email')\n    -&gt;text('corpo do email em texto simples')\n    -&gt;attach('\/caminho\/para\/arquivo.txt', 'nomepersonalizado.txt')\n    -&gt;send();\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3> 7. \u6dfb\u52a0\u81ea\u5b9a\u4e49\u6807\u5934 <\/h3>\n<p>\u60a8\u53ef\u4ee5\u5c06\u81ea\u5b9a\u4e49\u6807\u5934\u6dfb\u52a0\u5230\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u4e2d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>$mail = Mail::to('destinatario@dominio.com', 'Nome do Destinat\u00e1rio')\n    -&gt;subject('Assunto do Email')\n    -&gt;text('Corpo do email em texto simples')\n    -&gt;addHeader('X-Custom-Header', 'HeaderValue')\n    -&gt;send();\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2> \u6700\u540e\u7684\u8003\u8651\u56e0\u7d20 <\/h2>\n<p><strong>lithe mail<\/strong> \u63d0\u4f9b\u4e86\u4e00\u79cd\u5728 php \u5e94\u7528\u7a0b\u5e8f\u4e2d\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u7684\u5b9e\u7528\u4e14\u9ad8\u6548\u7684\u65b9\u6cd5\u3002\u901a\u8fc7\u5bf9\u73af\u5883\u53d8\u91cf\u548c\u5404\u79cd\u529f\u80fd\u7684\u652f\u6301\uff0c\u5b83\u53ef\u4ee5\u9002\u5e94\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u53d1\u9001\u9700\u6c42\u3002\u5c1d\u8bd5\u4e00\u4e0b\uff0c\u770b\u770b\u5982\u4f55\u6539\u5584\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6c9f\u901a\uff01<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5982\u679c\u60a8\u6709\u4efb\u4f55\u7591\u95ee\u6216\u5efa\u8bae\uff0c\u8bf7\u968f\u65f6\u5728\u4e0b\u9762\u8bc4\u8bba\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLithe Ml\uff1a\u7b80\u5316 PHP \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u7535\u5b50\u90ae\u4ef6\u53d1\u9001\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u597d\uff0c\u793e\u533a\uff01\u4eca\u5929\uff0c\u6211\u60f3\u5411\u60a8\u4ecb\u7ecd lithe ml\uff0c\u8fd9\u662f\u4e00\u4e2a\u7b80\u5316\u5728 php \u5e94\u7528\u7a0b\u5e8f\u4e2d\u901a\u8fc7 smtp \u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u7684\u8f6f\u4ef6\u5305\u3002\u5b83\u63d0\u4f9b\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u7075\u6d3b\u96c6\u6210\uff0c\u4f7f\u914d\u7f6e\u53d8\u5f97\u5bb9\u6613\u3002\u8ba9\u6211\u4eec\u770b\u770b\u5982\u4f55\u8bbe\u7f6e\u5e76\u5728\u60a8\u7684\u9879\u76ee\u4e2d\u4f7f\u7528\u5b83\u3002 \u5b89\u88c5 \u60a8\u53ef\u4ee5\u901a\u8fc7 \u5b89\u88c5\u8be5\u8f6f\u4ef6\u5305\u3002\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a composer require lithemod\/mail \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528 \u8fd9\u662f\u6709\u5173\u5982\u4f55\u4f7f\u7528\u8be5\u5305\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u7684\u7efc\u5408\u6307\u5357\uff1a 1\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf \u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a .env \u6587\u4ef6\u5e76\u914d\u7f6e\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u8bbe\u7f6e\uff1a mail_host=smtp.seuprovedor.com mail_port=587 mail_username=seu-email@dominio.com mail_password=sua-senha mail_encryption=tls mail_from_address=noreply@dominio.com mail_from_name=seu nome ou empresa \u767b\u5f55\u540e\u590d\u5236 2. \u53d1\u9001\u7b80\u5355\u7684\u6587\u672c\u7535\u5b50\u90ae\u4ef6 &lt;?php require &#8216;vendor\/autoload.php&#8217;; use lithesupportmail; use lithesupportenv; \/\/ carregar vari\u00e1veis de ambiente env::load(__dir__); \/\/ enviar o email $mail = mail::to(&#8216;destinatario@dominio.com&#8217;, &#8216;nome do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-26039","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=26039"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26039\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}