繁体   English   中英

使用Codeigniter发送电子邮件时出错

[英]Error sending email with codeigniter

我在Codeigniter中使用“电子邮件”库发送电子邮件时遇到小问题。

这是错误:

A PHP Error was encountered
Severity: Warning
Message:  mail() expects parameter 1 to be string, array given
Filename: libraries/Email.php
Line Number: 1553

这是我的代码,即我发送电子邮件请求的模型。

 $count = count($result);
    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => $correo, // change it to yours
        'smtp_pass' => '', // change it to yours
        'mailtype' => 'html',
        'charset' => 'utf-8',
        'newline' => "\r\n",
        'wordwrap' => TRUE
    );

    $body = "¡Hola! <br><br>";

    $body .= "Este e-mail  es para avisarte que has recibido un nuevo m ensaje " . $contexto . $result2[0]->nombre . ".<br><br>";
    $body .= "Contenido: <strong>" . $mensaje . ".<strong><br>";
    if ($tipo == 2) {
        $body .= "Entra a la aplicación Para confirmar tu asistencia.";
    }

    $this->load->library('Email');
    $this->load->library('Email', $config);
    $this->email->set_mailtype("html");
    $this->email->from($correo);
    for ($i = 0; $i < $count; $i++) {
        foreach ($result[$i] as $item) {
            $this->email->to($item);

        }
    }

    $this->email->subject($asunto);
    $this->email->message($body);
    $this->email->send();
}

}

我不知道为什么要发送此错误。 不胜感激任何帮助。

我知道,如果您不指定任何接收者($ this-> email-> to),则可能会遇到诸如以下问题:您确定$ count变量大于0吗? 您可以在没有循环的情况下尝试并仅发送至任何电子邮件地址以检查是否有效吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM