• <tfoot id='fp3RT'></tfoot>

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

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

        如何在 PHPMailer 中指定 SMTP 服务器?

        How to specify the SMTP server in PHPMailer?(如何在 PHPMailer 中指定 SMTP 服务器?)
      2. <legend id='BHp5w'><style id='BHp5w'><dir id='BHp5w'><q id='BHp5w'></q></dir></style></legend>
        <i id='BHp5w'><tr id='BHp5w'><dt id='BHp5w'><q id='BHp5w'><span id='BHp5w'><b id='BHp5w'><form id='BHp5w'><ins id='BHp5w'></ins><ul id='BHp5w'></ul><sub id='BHp5w'></sub></form><legend id='BHp5w'></legend><bdo id='BHp5w'><pre id='BHp5w'><center id='BHp5w'></center></pre></bdo></b><th id='BHp5w'></th></span></q></dt></tr></i><div id='BHp5w'><tfoot id='BHp5w'></tfoot><dl id='BHp5w'><fieldset id='BHp5w'></fieldset></dl></div>

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

          <tbody id='BHp5w'></tbody>

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

                  <tfoot id='BHp5w'></tfoot>
                  本文介绍了如何在 PHPMailer 中指定 SMTP 服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道如何让 SMTP 服务器使用 PHPMailer 使用我创建的电子邮件 (email@mydomain.com) 发送自动电子邮件.

                  I want to know how do I get a SMTP server to use PHPMailer to send automatic emails with my created email (email@mydomain.com).

                  我的虚拟主机没有提供.我在 OnlyDomains 中引入了我的域,而我的虚拟主机是 000Webhost.

                  My webhost doesn't provide one. I brought my domain in OnlyDomains and my webhost is 000Webhost.

                  <?php
                  require './PHPMailer-master/PHPMailerAutoload.php';
                  
                  $mail = new PHPMailer;
                  
                  $mail->isSMTP();                                      // Set mailer to use SMTP
                  $mail->Host = '';  // Specify main and backup SMTP servers
                  $mail->SMTPAuth = true;                               // Enable SMTP authentication
                  $mail->Username = 'noreply@mydomain.com';                 // SMTP username
                  $mail->Password = '********';                           // SMTP password
                  $mail->SMTPSecure = 'tls';                            
                  $mail->From = 'noreply@mydomain.com';
                  $mail->FromName = 'Admin';
                  $mail->addAddress('sdfsdf@hotmail.com');               // Name is optional
                  
                  $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
                  $mail->isHTML(true);                                  // Set email format to HTML
                  
                  $mail->Subject = 'swag';
                  $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
                  $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
                  
                  if(!$mail->send()) {
                  echo 'Message could not be sent.';
                  echo 'Mailer Error: ' . $mail->ErrorInfo;
                  } else {
                  echo 'Message has been sent';
                  }
                  ?>
                  

                  推荐答案

                  你应该看看你的虚拟主机是否允许你在他们的系统上使用 sendmail.sendmail 不需要 STMP.他们很有可能会这样做,因为它是大多数 Linux/Unix 设置的标准部分.既然你说你的网络主机是 000WebHost 似乎他们确实支持使用 sendmail:

                  You should see if your web host allows you to use sendmail on their system. STMP is not needed with sendmail. Chances are they do since it is a standard part of most any Linux/Unix setup. And since you say that your web host is 000WebHost it seems like they do support the use of sendmail:

                  您可以使用 PHP 的 mail() 函数为您的访问者发送邮件……

                  You can use PHP's mail() function to send mail for your visitors…

                  但他们似乎也在 他们的高级套餐中提供 SMTP.

                  But they also seem to offer SMTP in their premium package.

                  过去,我建议不要担心 SMTP 和现在坚持使用 sendmail.查看 PHPMailer 的文档,似乎该库可以使用 sendmail:

                  Past that, I would recommend not worrying about SMTP & sticking to sendmail for now. Looking at the documentation for PHPMailer it seems that the library can use sendmail:

                  PHP mail() 函数通常通过本地邮件服务器发送,通常在 Linux、BSD 和 OS X 上以 sendmail 二进制文件开头平台,但是,Windows 通常不包含本地邮件服务器;PHPMailer 的集成 SMTP 实现允许电子邮件在没有本地邮件服务器的 Windows 平台上发送.

                  The PHP mail() function usually sends via a local mail server, typically fronted by a sendmail binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.

                  然后查看 PHPMailer 存储库 examples/ 文件夹/sendmail.phps" rel="nofollow">显示有一个 sendmail 例子:

                  Then looking in the examples/ folder in the PHPMailer repository shows there is a sendmail example:

                  require '../PHPMailerAutoload.php';
                  
                  //Create a new PHPMailer instance
                  $mail = new PHPMailer();
                  
                  // Set PHPMailer to use the sendmail transport
                  $mail->isSendmail();
                  
                  //Set who the message is to be sent from
                  $mail->setFrom('from@example.com', 'First Last');
                  
                  //Set an alternative reply-to address
                  $mail->addReplyTo('replyto@example.com', 'First Last');
                  
                  //Set who the message is to be sent to
                  $mail->addAddress('whoto@example.com', 'John Doe');
                  
                  //Set the subject line
                  $mail->Subject = 'PHPMailer sendmail test';
                  
                  //Read an HTML message body from an external file, convert referenced images to embedded,
                  //convert HTML into a basic plain-text alternative body
                  $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
                  
                  //Replace the plain text body with one created manually
                  $mail->AltBody = 'This is a plain-text message body';
                  
                  //Attach an image file
                  $mail->addAttachment('images/phpmailer_mini.png');
                  
                  //send the message, check for errors
                  if (!$mail->send()) {
                      echo "Mailer Error: " . $mail->ErrorInfo;
                  } else {
                      echo "Message sent!";
                  }
                  

                  这篇关于如何在 PHPMailer 中指定 SMTP 服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 服务器发送电子邮件时,电子邮件进入垃圾邮件)
                    <legend id='HoOYN'><style id='HoOYN'><dir id='HoOYN'><q id='HoOYN'></q></dir></style></legend>

                      <tbody id='HoOYN'></tbody>
                  1. <small id='HoOYN'></small><noframes id='HoOYN'>

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

                        <tfoot id='HoOYN'></tfoot>
                          • <bdo id='HoOYN'></bdo><ul id='HoOYN'></ul>