重复的PHP电子邮件

问题描述 投票:0回答:1

使用php发送的电子邮件将被发送两次。我的应用程序在Codeigniter中,我正在使用它的邮件。为了测试目的,我现在已经在Codeigniter控制器中创建了下面的函数,我仍然发送两封电子邮件。

这是测试功能:

public function testSend(){
        $to      = "[email protected]";
        $subject = "HTML email Test from testSend";

        $message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
"; 

//$message = $this->getMessage($data);
// Always set content-type when sending HTML email
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
        $headers .= 'From: <[email protected]>' . "\r\n";
//$headers .= 'Cc: [email protected]' . "\r\n";

        $result = mail($to, $subject, $message, $headers);

        if ($result)
        {
            echo "mail sent sucessfully";
        } else
        {
            echo "mail failed";
        }

        exit;
    }

上面的函数基本上是PHP邮件手册页的复制和粘贴。

我怀疑它是否相关,但如果我尝试在没有函数调用的情况下从基于函数的脚本发送邮件,则会失败。

php codeigniter email
1个回答
0
投票

重复的电子邮件是由Chrome中的某些内容引起的,而不是php或Codeigniter问题。使用fireFox导致没有重复。该程序在服务器上以cron方法运行,因此它永远不会发送重复项。

© www.soinside.com 2019 - 2024. All rights reserved.