<legend id='ySmnu'><style id='ySmnu'><dir id='ySmnu'><q id='ySmnu'></q></dir></style></legend>

    1. <small id='ySmnu'></small><noframes id='ySmnu'>

      <i id='ySmnu'><tr id='ySmnu'><dt id='ySmnu'><q id='ySmnu'><span id='ySmnu'><b id='ySmnu'><form id='ySmnu'><ins id='ySmnu'></ins><ul id='ySmnu'></ul><sub id='ySmnu'></sub></form><legend id='ySmnu'></legend><bdo id='ySmnu'><pre id='ySmnu'><center id='ySmnu'></center></pre></bdo></b><th id='ySmnu'></th></span></q></dt></tr></i><div id='ySmnu'><tfoot id='ySmnu'></tfoot><dl id='ySmnu'><fieldset id='ySmnu'></fieldset></dl></div>

      • <bdo id='ySmnu'></bdo><ul id='ySmnu'></ul>

      <tfoot id='ySmnu'></tfoot>

      如何配置 PHP 发送电子邮件?

      How to configure PHP to send e-mail?(如何配置 PHP 发送电子邮件?)

              <tbody id='YrltJ'></tbody>
                <bdo id='YrltJ'></bdo><ul id='YrltJ'></ul>

                <legend id='YrltJ'><style id='YrltJ'><dir id='YrltJ'><q id='YrltJ'></q></dir></style></legend>
              • <tfoot id='YrltJ'></tfoot>
              • <small id='YrltJ'></small><noframes id='YrltJ'>

              • <i id='YrltJ'><tr id='YrltJ'><dt id='YrltJ'><q id='YrltJ'><span id='YrltJ'><b id='YrltJ'><form id='YrltJ'><ins id='YrltJ'></ins><ul id='YrltJ'></ul><sub id='YrltJ'></sub></form><legend id='YrltJ'></legend><bdo id='YrltJ'><pre id='YrltJ'><center id='YrltJ'></center></pre></bdo></b><th id='YrltJ'></th></span></q></dt></tr></i><div id='YrltJ'><tfoot id='YrltJ'></tfoot><dl id='YrltJ'><fieldset id='YrltJ'></fieldset></dl></div>
                本文介绍了如何配置 PHP 发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要使用 php 脚本向我网站的用户发送邮件.我曾尝试在 php 中使用邮件功能.
                我的代码如下:

                I need to send mail to the users of my website using php script. I have tried using mail function in php.
                My code is as follows:

                  $to = "myweb@gmail.com";
                  $subject = "Test mail";
                  $message = "My message";
                  $from = "webp@gmail.com";
                  $headers = "From:" . $from;
                  mail($to,$subject,$message,$headers);
                

                当我尝试运行程序时,我得到了:

                When I try running the program this is what I get:

                 Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set().
                

                请告诉我要在 $from 变量中包含什么地址.我需要一个 smtp 服务器吗?如何使用 localhost 发送邮件?请告诉我在 php.ini 文件中具体要编辑什么

                Please tell me what address to include in the $from variable. Do I need a smtp server for this? How do I send mails using a localhost? Please tell me what exactly to edit in the php.ini file

                我对这一切都不熟悉..请帮助我..

                I am new to all this.. Please help me..

                推荐答案

                改用 PHPMailer:https://github.com/PHPMailer/PHPMailer

                Use PHPMailer instead: https://github.com/PHPMailer/PHPMailer

                使用方法:

                require('./PHPMailer/class.phpmailer.php');
                $mail=new PHPMailer();
                $mail->CharSet = 'UTF-8';
                
                $body = 'This is the message';
                
                $mail->IsSMTP();
                $mail->Host       = 'smtp.gmail.com';
                
                $mail->SMTPSecure = 'tls';
                $mail->Port       = 587;
                $mail->SMTPDebug  = 1;
                $mail->SMTPAuth   = true;
                
                $mail->Username   = 'me.sender@gmail.com';
                $mail->Password   = '123!@#';
                
                $mail->SetFrom('me.sender@gmail.com', $name);
                $mail->AddReplyTo('no-reply@mycomp.com','no-reply');
                $mail->Subject    = 'subject';
                $mail->MsgHTML($body);
                
                $mail->AddAddress('abc1@gmail.com', 'title1');
                $mail->AddAddress('abc2@gmail.com', 'title2'); /* ... */
                
                $mail->AddAttachment($fileName);
                $mail->send();
                

                这篇关于如何配置 PHP 发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)
                  <tbody id='LImQw'></tbody>

                    <bdo id='LImQw'></bdo><ul id='LImQw'></ul>
                    <legend id='LImQw'><style id='LImQw'><dir id='LImQw'><q id='LImQw'></q></dir></style></legend>
                      1. <i id='LImQw'><tr id='LImQw'><dt id='LImQw'><q id='LImQw'><span id='LImQw'><b id='LImQw'><form id='LImQw'><ins id='LImQw'></ins><ul id='LImQw'></ul><sub id='LImQw'></sub></form><legend id='LImQw'></legend><bdo id='LImQw'><pre id='LImQw'><center id='LImQw'></center></pre></bdo></b><th id='LImQw'></th></span></q></dt></tr></i><div id='LImQw'><tfoot id='LImQw'></tfoot><dl id='LImQw'><fieldset id='LImQw'></fieldset></dl></div>

                        <small id='LImQw'></small><noframes id='LImQw'>

                          <tfoot id='LImQw'></tfoot>