<tfoot id='fpfhE'></tfoot>

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

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

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

    1. 为 php mail() 函数设置 SMTP 详细信息

      Setting SMTP details for php mail () function(为 php mail() 函数设置 SMTP 详细信息)

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

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

          1. <legend id='vgdx8'><style id='vgdx8'><dir id='vgdx8'><q id='vgdx8'></q></dir></style></legend>

          2. <tfoot id='vgdx8'></tfoot>

                <tbody id='vgdx8'></tbody>
                <bdo id='vgdx8'></bdo><ul id='vgdx8'></ul>
              • 本文介绍了为 php mail() 函数设置 SMTP 详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我一直在寻找答案并尝试了很多方法来解决这个问题.

                I have been looking for an answer and tried many things to this problem.

                我的脚本在我的虚拟主机上运行良好,但是当将其移动到其他专用服务器时,邮件永远不会送达.现在我需要设置 SMTP 服务器,但不正确.

                My script works fine on my webhost but when moving it to an other dedicated server the mail never gets delivered. Now i need to set the SMTP server but don't get it right.

                顺便说一句,使用 Gmail 应用程序.这就是代码的样子.

                Using Gmail apps btw. This is how the code looks like.

                <?php
                
                if(!$_POST) exit;
                
                $email = $_POST['email'];
                
                
                //$error[] = preg_match('/[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
                if(!eregi("@",$email )){
                    $error.="Invalid email address entered";
                    $errors=1;
                }
                if($errors==1) echo $error;
                else{
                    $values = array ('name','email','telephone','message');
                    $required = array('name','email','telephone','message');
                
                    $your_email = "xxx@example.com";
                    $email_subject = "New Messag: ".$_POST['subject'];
                    $email_content = "New message:
                ";
                
                    foreach($values as $key => $value){
                      if(in_array($value,$required)){
                        if ($key != 'subject' && $key != 'telephone') {
                          if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
                        }
                        $email_content .= $value.': '.$_POST[$value]."
                ";
                      }
                    }
                
                    if(@mail($your_email,$email_subject,$email_content)) {
                        echo 'Message sent!'; 
                    } else {
                        echo 'ERROR!';
                    }
                }
                
                $mail->Mailer = "smtp";  
                $mail->Host = "ssl://smtp.gmail.com";  
                $mail->Port = 465;  
                $mail->SMTPAuth = true; // turn on SMTP authentication  
                $mail->Username = "user@gmail.com"; // SMTP username  
                $mail->Password = "password"; // SMTP password 
                
                ?>
                

                那么我该如何正确设置 SMTP 设置呢?

                So how do i set the SMTP settings right?

                推荐答案

                仅适用于 Windows: 您可以尝试使用 ini_set() 函数Docs 用于 SMTPDocssmtp_port文档设置:

                Under Windows only: You may try to use ini_set() functionDocs for the SMTPDocs and smtp_portDocs settings:

                ini_set('SMTP', 'mysmtphost'); 
                ini_set('smtp_port', 25); 
                

                这篇关于为 php mail() 函数设置 SMTP 详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                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 的问题)

                <legend id='ezWdn'><style id='ezWdn'><dir id='ezWdn'><q id='ezWdn'></q></dir></style></legend>
                  <tbody id='ezWdn'></tbody>

                  1. <tfoot id='ezWdn'></tfoot>
                      • <bdo id='ezWdn'></bdo><ul id='ezWdn'></ul>

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

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