[英]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.