codeigniter电子邮件奇怪 [英] codeigniter email weirdness

查看:111
本文介绍了codeigniter电子邮件奇怪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过codeigniter框架通过两种不同的方式发送电子邮件,其中一个我的电子邮件去垃圾文件夹,但它真的很奇怪...



so我的第一个尝试是创建一个Controller,并将索引函数放在以下代码中:

  $ this-> load-> ;库( '电子邮件'); 
$ this-> email-> from('no-reply@domain.example.com','Your Name');
$ this-> email-> to('email@example.com');
$ this-> email-> subject('Email Test');
$ this-> email-> message('测试电子邮件类');
$ this-> email-> send();
echo $ this-> email-> print_debugger();

这种方式的电子邮件收到罚款,而不是垃圾邮件...



当我创建一个模型,所以我可以使用它以后的其他功能发送电子邮件我替换上面的代码与以下代码:

  $ this-> load-> library('email'); 
$ this-> load-> model(email_model);
$ this-> email_model-> sendEmail(null,'email@gmail.com','title','message');

和email_model模型包含以下代码:

 <?php 
class email_model扩展CI_Model {

函数__construct()
{
//调用模型构造函数
parent :: __ construct();
}

public function sendEmail($ from = null,$ to = null,$ subject = null,$ message = null){
$ this-> email-> ; from('no-reply@domain.com','from user');
$ this-> email-> to($ to);
$ this-> email-> subject($ subject);
$ this-> email-> message($ message);
$ this-> email-> send();
}
}

为什么会这样?

解决方案

似乎内容是第二次尝试的原因...添加更多文本解决了问题...


I am trying to send email via codeigniter framework via 2 different ways and on one of them my email goes to junk folder but its really weird...

so my first try was to create a Controller and put inside the index function the following code:

    $this->load->library('email');
    $this->email->from('no-reply@domain.example.com', 'Your Name');
    $this->email->to('email@example.com');
    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');
    $this->email->send();
    echo $this->email->print_debugger();

this way the email arrives fine and not as spam...

when i create a model so i can use it later on for other features to send emails i replace the above code with the following one:

    $this->load->library('email');
    $this->load->model("email_model");
    $this->email_model->sendEmail(null, 'email@gmail.com', 'title', 'message');

and email_model Model contains the following code :

<?php
class email_model extends CI_Model {

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

   public function sendEmail($from = null, $to = null, $subject = null, $message = null){
        $this->email->from('no-reply@domain.com', 'from user');
        $this->email->to($to);
        $this->email->subject($subject);
        $this->email->message($message);
        $this->email->send();
   }
}

why does that happen?

解决方案

seems content was the reason on the 2nd try... adding more text solved the issue...

这篇关于codeigniter电子邮件奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆