• <small id='jARti'></small><noframes id='jARti'>

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

        使用 Gmail SMTP 通过 PHP 发送电子邮件

        Using Gmail SMTP to send email with PHP(使用 Gmail SMTP 通过 PHP 发送电子邮件)
      3. <i id='SqybG'><tr id='SqybG'><dt id='SqybG'><q id='SqybG'><span id='SqybG'><b id='SqybG'><form id='SqybG'><ins id='SqybG'></ins><ul id='SqybG'></ul><sub id='SqybG'></sub></form><legend id='SqybG'></legend><bdo id='SqybG'><pre id='SqybG'><center id='SqybG'></center></pre></bdo></b><th id='SqybG'></th></span></q></dt></tr></i><div id='SqybG'><tfoot id='SqybG'></tfoot><dl id='SqybG'><fieldset id='SqybG'></fieldset></dl></div>

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

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

                    <tbody id='SqybG'></tbody>

                • <tfoot id='SqybG'></tfoot>
                • <legend id='SqybG'><style id='SqybG'><dir id='SqybG'><q id='SqybG'></q></dir></style></legend>
                  本文介绍了使用 Gmail SMTP 通过 PHP 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个问题已经解决了大约一周,但找不到答案.作为这一切的序言,我已经在互联网上搜索了各种各样的东西.这个问题有很多答案,但似乎没有一个对我有帮助.

                  I have a problem I have been working on for about a week and can't find an answer. As a preface to this all, I have searched the internet for all sorts of things. There are a lot of answers for this problem, but none seem to be helping me.

                  我对 PHP 和我要求的很多东西有点陌生(过去几个月一直在使用它).让我进入问题的根源:

                  I am somewhat new to PHP and a lot of the stuff I am asking for (been using it over the past few months). Let me get to the base of the problem:

                  我在一个学校网络上,我在宿舍里设置了自己的服务器.我正在创建一个需要验证用户电子邮件的网站,但基本的 PHP mail() 函数不起作用.有人告诉我,我需要使用 SMTP.所以我决定最简单和最便宜的方法是使用 Gmail SMTP.为此,我在 Gmail 上创建了一个名为 verify.impressions@gmail.com 的帐户.这是代码.

                  I am on a school network with my own server set up in my dorm room. I am creating a website where I need to verify a user's email, but the basic PHP mail() function does not work. I have been told that I will need to use SMTP. So I decided the easiest and cheapest way was with Gmail SMTP. I created an account on Gmail called verify.impressions@gmail.com for this reason. Here is the code.

                  echo "starting mail sending";
                               require_once("pear/share/pear/Mail.php");
                  
                  echo "1";
                  
                  $from = "PersonA `<someone@gmail.com`>";   $to = "`<someoneElse@email.com`>";   $subject = "Activate your account";   $body = "Hey";  
                  
                  $host = "ssl://smtp.gmail.com";   $port = "465"; //also tried 587   $username = "someone@gmail.com";   $password = "password";  
                  
                  echo "2";
                  
                  $headers = array ('From' => $from,    'To' => $to,    'Subject' => $subject);
                  
                  echo "3";
                  
                  $mailer_params['host'] = $host;   $mailer_params['port'] = $port;   $mailer_params['auth'] = true;   $mailer_params['username'] = $username;   $mailer_params['password'] = $password;                                              
                                   $smtp = Mail::factory('smtp', $mailer_params);
                  
                  echo "4";
                  
                  error_reporting(E_ALL);
                  
                  echo "5";
                  
                  if (PEAR::isError($smtp)) {   die("Error : " . $smtp->getMessage()); }
                  
                  echo "6";
                  
                  $mail = $smtp->send($to, $headers, $body) or die("Something bad happened"); 
                  
                  echo "7";
                  
                  if (PEAR::isError($mail)) {echo($mail->getMessage();} else {echo(Message successfully sent!);}
                                   echo "mail sent hopefully.";
                  

                  所以基本上代码就停在这一行:

                  So basically the code just stops at the line:

                  $mail = $smtp->send($to, %headers, $);
                  

                  我尝试过打印错误,但我现在不知道该怎么办.任何提示和帮助表示赞赏.谢谢!!

                  I have tried printing errors, but I just have no idea what to do now. Any tips and help is appreciated. Thanks!!

                  推荐答案

                  使用这个类:http://www.phpclasses.org/package/14-PHP-Sends-e-mail-messages-via-SMTP-protocol.html

                  我使用的示例代码:

                  require("smtp/smtp.php");
                  require("sasl/sasl.php");
                  $from = 'youraddress@gmail.com';
                  $to = 'some@email.com';
                  
                  $smtp=new smtp_class;
                  $smtp->host_name="smtp.gmail.com";
                  $smtp->host_port='465';
                  $smtp->user='youraddress@gmail.com';
                  $smtp->password='XXXXXXXXX';
                  $smtp->ssl=1;
                  $smtp->debug=1;       //0 here in production
                  $smtp->html_debug=1; //same
                  
                  $smtp->SendMessage($from,array($to),array(
                  "From: $from",
                  "To: $to",
                  "Subject: Testing Manuel Lemos' SMTP class",
                  "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
                  ),
                  "Hello $to,
                  
                  It is just to let you know that your SMTP class is working just fine.
                  
                  Bye.
                  "));
                  

                  这篇关于使用 Gmail SMTP 通过 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='s838b'></tbody>
                  <tfoot id='s838b'></tfoot>

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

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