Я спробував використати цей код
$config = array(
"protocol" => "smtp",
"smtp_host" => "localhost",
"smtp_port" => 465,
"smtp_user" => "email@gmail.com",
"smtp_pass" => "password",
"mailtype" => "html",
"mailpath" => "/usr/sbin/sendmail",
"charset" => "iso-8859-1",
"wordwrap" => TRUE
);
$this->load->library("email", $config);
$message = "";
$this->load->library("email", $config);
$this->email->set_newline("rn");
$this->email->from("email@gmail.com"); // change it to yours
$this->email->to("email1@gmail.com"); // change it to yours
$this->email->subject("Resume from JobsBuddy for your Job posting");
$this->email->message($message);
if ($this->email->send()) {
echo "Email sent.";
} else {
show_error($this->email->print_debugger());
}
У цьому випадку електронна пошта надіслана, але вхідні, спам, кошик не знайдено. будь ласка, допоможіть мені
Відповіді:
0 для відповіді № 1Ви не можете надсилати електронні листи з вашого localhost як something@gmail.com. Можливо, ваш електронний лист потрапив у чорний список, оскільки ваш локальний SMTP не є gmail.com. Для цього потрібно використовувати SMTP для Gmail.
0 для відповіді № 2
Оскільки ви намагаєтеся використовувати локальний хост, повідомлення електронної пошти та його вміст не пройшли автентифікацію. Використовуйте хост SMTP google.
$config = Array(
"protocol" => "smtp",
"smtp_host" => "ssl://smtp:googlemail.com",
"smtp_port" => 465,
"smtp_user" => "myemail@gmail.com",
"smtp_password" => "mypassword",
);
$this->load->library("email", $config);
$this->email->set_newline("rn");
$this->email->from("setfromemail@gmail.com", "FirstName LastName");
$this->email->to("myemail@gmail.com");
$this->email->subject("subject test");
$this->email->message("this is the body");
if($this->email->send())
{
echo "mail sent";
}
else
{
show_error($this->email->print_debugger());
}