【问题标题】:Cakephp mail is not sending to mail idCakephp 邮件未发送到邮件 ID
【发布时间】:2013-09-06 14:46:18
【问题描述】:

在我的代码中,邮件未发送到邮件 ID,但数据正在插入表中 这里附上我的控制器代码

function supportrequest()
    {
        $heading = 'DATA CENTER SUPPORT';
        $this->set('heading', $heading);

        if(!empty($this->data))
        {
            $this->data['SupportRequest']['date'] = date('Y-m-d H:i:s');
            $this->data['SupportRequest']['supportId'] = 'SRID-'.$this->uuid();
            $SRID = $this->data['SupportRequest']['supportId'];
            $this->data['SupportRequest']['name'] = strtolower($this->data['SupportRequest']['name']);
            $this->data['SupportRequest']['status'] = 'Open';
            //print_r($this->data);
            /*$adminurl = "https://www.antzmedia.com/admin/supportrequestlogin/sid:".$this->data['SupportRequest']['supportId'];
            $message  = "You have a new support request from a customer. Please follow the below link to see the support request.<br/><br/>";
            $message .= $adminurl;


            //$to = "marvil@antzmedia.org";
            $to         = "support@antzmedia.org";
            $subject    = "Support Request Entry";
            // To send HTML mail, the Content-type header must be set
            $headers = "MIME-Version: 1.0\r\n"
                      ."Content-Type: text/html; charset=iso-8859-1\r\n"
                      ."Content-Transfer-Encoding: 8bit\r\n"
                      ."From: =?UTF-8?B?". base64_encode($this->data['SupportRequest']['name']) ."?= <".$this->data['SupportRequest']['email'].">\r\n"
                      ."X-Mailer: PHP/". phpversion();

            mail($to, $subject, $message, $headers);*/

            $userurl    = Router::url('/', true)."home/supportrequeststatus/sid:".$SRID;
            $to2        = $this->data['SupportRequest']['email'];
            $subject2   = "Support Request Info";
            /*$message2   = "You have received this mail because you have made a support request to Antz Media.<br/>
                           Your concern has been registered and our support team will be in touch with you soon.<br/>
                           This is your Support Request ID : <b style=color:green>".$this->data['SupportRequest']['supportId']."</b><br/>
                           Use this ID to track the progress of your queries.<br/>
                           Please follow this url to get your support request status : ".$userurl."<br/><br/>
                           Thankyou.";*/

            $message2 = '<table cellspacing="0" cellpadding="8" border="0" width="600"  style=" background:#B9FFEF; border-radius: 5px 5px 5px 5px; ">
                    <tr>
                    <td colspan="2"><strong>Greetings From CTL !!!</strong></td>
                    </tr>
                    <td style="font-family:Verdana, Arial; font-size:14px; color:#333333;">Your query has been successfully submitted.</td>
                    <tr >                                       
                    <td style="font-family:Verdana, Arial; font-size:14px; color:#333333;">Your Support Request ID :<font color="green"><b>'.$this->data['SupportRequest']['supportId'].'</b></font></td>
                    </tr>                   
                    <tr >   
                    <td style="font-family:Verdana, Arial; font-size:14px; color:#333333;">Use this ID to track the progress of your query. Our Technical Support Team will surely assist you to resolve your concern.</td>         
                    </tr>
                    <tr></tr>
                    <tr >
                    <td style="font-family:Verdana, Arial; font-size:13px; color:#333333;">Click <font color="blue">'.$userurl.' </font>to check your status.</td>                                    
                    </tr>                                    
                    </table>';             


            $headers2 = "MIME-Version: 1.0\r\n"
                      ."Content-Type: text/html; charset=iso-8859-1\r\n"
                      ."Content-Transfer-Encoding: 8bit\r\n"
                      ."From: =?UTF-8?B?". base64_encode("CTL") ."?= <admin@noreply.com>\r\n"
                      ."X-Mailer: PHP/". phpversion();

            mail($to2, $subject2, $message2, $headers2);

            if ($this->SupportRequest->save($this->data))
            {
                $this->Session->setFlash('<br/>Support Request has been submitted successfully.<br/><br/>
                 Your Unique Support Request ID ( <b>'.$SRID.'</b> ) has been sent to your E-mail.<br/><br/>
                 For further updates,please check your E-mail Inbox / Junk Folder or our website regularly.<br/><br/>','default',array('class' =>'successbox'));
                $this->redirect('/home/supportrequest');
            }
            else
            {
                $this->Session->setFlash('Something went wrong please try again after refreshing the page.','default',array('class' =>'errorbox'));
            }
        }
    }

我尝试了很多电子邮件 ID,但同样的情况正在发生...这意味着没有邮件发送到提供的邮件 ID...。

【问题讨论】:

  • 您使用的是哪个版本的 cakephp?你有在 php.ini 中启用邮件吗?
  • Cakephp 版本为 1.3.8
  • 你在php.ini中启用邮件了吗?
  • 我在远程运行它..那么我如何在 php.ini 中启用它
  • 你好 Er.KT ... Atlast 我明白了..现在邮件工作正常...你帮了我很多...问题是我已经 coomented 一个代码...谢谢

标签: php html email cakephp ctp


【解决方案1】:

要检查您的服务器上的邮件发送是否正常,请尝试在一个文件中执行以下代码并将此文件(比如说 testmail.php)保存在 webroot 中并在 yourdomain.com/testmail.php 上检查它

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?> 

我不能把这个答案放在评论中,所以这就是我在这里发帖的原因

【讨论】:

  • 我收到邮件已发送
  • 好意味着邮件发送在您的服务器上工作现在您的 cakephp 代码有问题
  • 当我在代码 write('debug', 0) 中将“0”编辑为“1”或“2”时会发生什么
  • 是调试级别,会显示错误,php脚本中的警告,设置为2
  • $message2 = ' tr>
    来自 CTL 的问候!!!
    您的查询已成功提交。
    您的支持请求 ID:'.$this->data['SupportRequest']['supportId'].'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-19
  • 2014-07-20
  • 2014-01-17
  • 1970-01-01
  • 2013-07-18
相关资源
最近更新 更多