<bdo id='W7W0k'></bdo><ul id='W7W0k'></ul>

      <tfoot id='W7W0k'></tfoot>

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

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

        如何从本地主机发送 smtp 邮件

        时间:2024-08-23

      3. <tfoot id='r2q5W'></tfoot>

            <bdo id='r2q5W'></bdo><ul id='r2q5W'></ul>
                <tbody id='r2q5W'></tbody>
              • <small id='r2q5W'></small><noframes id='r2q5W'>

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

                1. 本文介绍了如何从本地主机发送 smtp 邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  尝试从本地主机发送电子邮件时,我总是收到此消息.

                  I always get this message when trying to send email from my local host.

                  SMTP 错误:无法连接到 SMTP 主机.无法发送消息.邮件程序错误:SMTP 错误:无法连接到 SMTP 主机.

                  SMTP Error: Could not connect to SMTP host. Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.

                  下面是我的代码:请帮忙

                  below is my code: please help

                  <?php
                  
                  // $email and $message are the data that is being
                  // posted to this page from our html contact form
                  $email = $_REQUEST['email'] ;
                  $message = $_REQUEST['message'] ;
                  
                  // When we unzipped PHPMailer, it unzipped to
                  // public_html/PHPMailer_5.2.0
                  require("class.phpmailer.php");
                  
                  $mail = new PHPMailer();
                  
                  // set mailer to use SMTP
                  $mail->IsSMTP();
                  
                  // As this email.php script lives on the same server as our email server
                  // we are setting the HOST to localhost
                  $mail->Host = "localhost";  // specify main and backup server
                  
                  $mail->SMTPAuth = true;     // turn on SMTP authentication
                  
                  // When sending email using PHPMailer, you need to send from a valid email address
                  // In this case, we setup a test email account with the following credentials:
                  // email: send_from_PHPMailer@bradm.inmotiontesting.com
                  // pass: password
                  $mail->Username = "project@reliable.com.pk";  // SMTP username
                  $mail->Password = "Nov112014"; // SMTP password
                  
                  // $email is the user's email address the specified
                  // on our contact us page. We set this variable at
                  // the top of this page with:
                  // $email = $_REQUEST['email'] ;
                  $mail->From = $email;
                  
                  // below we want to set the email address we will be sending our email to.
                  $mail->AddAddress("mani9418@gmail.com", "Usman Ali Siddiqui");
                  
                  // set word wrap to 50 characters
                  $mail->WordWrap = 50;
                  // set email format to HTML
                  $mail->IsHTML(true);
                  
                  $mail->Subject = "You have received feedback from your website Etutionhub!";
                  
                  // $message is the user's message they typed in
                  // on our contact us page. We set this variable at
                  // the top of this page with:
                  // $message = $_REQUEST['message'] ;
                  $mail->Body    = $message;
                  $mail->AltBody = $message;
                  
                  if(!$mail->Send())
                  {
                     echo "Message could not be sent. <p>";
                     echo "Mailer Error: " . $mail->ErrorInfo;
                     exit;
                  }
                  
                  echo "Message has been sent";
                  ?>

                  推荐答案

                  1. 打开 php.ini.对于 XAMPP,它位于 C:XAMPPphpphp.ini 中.了解您使用的是 WAMP 还是 LAMP 服务器.
                    注意:备份php.ini文件.

                  1. Open the php.ini. For XAMPP, it is located in C:XAMPPphpphp.ini. Find out if you are using WAMP or LAMP server.
                    Note: Make a backup of php.ini file.

                  在php.ini文件中搜索【邮件功能】.

                  Search [mail function] in the php.ini file.

                  You can find like below.
                  [mail function]
                  ; For Win32 only.
                  ; http://php.net/smtp
                  SMTP = localhost
                  ; http://php.net/smtp-port
                  smtp_port = 25
                  
                  ; For Win32 only.
                  ; http://php.net/sendmail-from
                  ;sendmail_from = postmaster@localhost
                  

                  将 localhost 更改为 ISP 的 smtp 服务器名称.无需更改 smtp_port.将其保留为 25.将 sendmail_frompostmaster@localhost 更改为您的域电子邮件地址,该地址将用作发件人地址.

                  Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25. Change sendmail_from from postmaster@localhost to your domain email address which will be used as from address.

                  所以对我来说,会变成这样.

                  So for me, it will become like this.

                  [mail function]
                  ; For Win32 only.
                  SMTP = smtp.example.com
                  smtp_port = 25
                  ; For Win32 only.
                  sendmail_from = info@example.com
                  

                2. 重新启动 XAMPP 或 WAMP(apache 服务器),以便更改开始工作.

                3. Restart the XAMPP or WAMP(apache server) so that changes will start working.

                  现在尝试使用 mail() 函数发送邮件.

                  Now try to send the mail using the mail() function.

                  mail("example@example.com","Success","Great, Localhost Mail works");
                  

                4. 邮件将从 localhost 发送到 example@example.com,主题行Success",正文Great, Localhost Mail works".

                  Mail will be sent to example@example.com from the localhost with Subject line "Success" and body "Great, Localhost Mail works".

                  这篇关于如何从本地主机发送 smtp 邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Codeigniter 电子邮件错误处理 下一篇:Godaddy服务器上的PHPMailer,设置正确吗?

                  相关文章

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

                5. <i id='ivujf'><tr id='ivujf'><dt id='ivujf'><q id='ivujf'><span id='ivujf'><b id='ivujf'><form id='ivujf'><ins id='ivujf'></ins><ul id='ivujf'></ul><sub id='ivujf'></sub></form><legend id='ivujf'></legend><bdo id='ivujf'><pre id='ivujf'><center id='ivujf'></center></pre></bdo></b><th id='ivujf'></th></span></q></dt></tr></i><div id='ivujf'><tfoot id='ivujf'></tfoot><dl id='ivujf'><fieldset id='ivujf'></fieldset></dl></div>
                6. <small id='ivujf'></small><noframes id='ivujf'>

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

                    1. <tfoot id='ivujf'></tfoot>