Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter未使用SMTP发送电子邮件_Php_Codeigniter_Email_Smtp - Fatal编程技术网

Php CodeIgniter未使用SMTP发送电子邮件

Php CodeIgniter未使用SMTP发送电子邮件,php,codeigniter,email,smtp,Php,Codeigniter,Email,Smtp,我正在使用我的域详细信息发送带有CodeIgniter SMTP的电子邮件,但电子邮件不会发送。这是我的设置: $full_name = 'xxx'; $from = $email = 'info@manazelspecilists.com'; $configs = Array( 'protocol' => 'smtp', 'smtp_host' => 'mail.manazelspecialists.ae', 'smtp_port' =&

我正在使用我的域详细信息发送带有CodeIgniter SMTP的电子邮件,但电子邮件不会发送。这是我的设置:

 $full_name =  'xxx';
 $from = $email = 'info@manazelspecilists.com';
 $configs = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'mail.manazelspecialists.ae',
      'smtp_port' => 587,
      'smtp_user' => 'support@manazelspecialists.ae',
      'smtp_pass' => 'xxxx',
      'mailtype' => 'html',
      'charset' => 'iso-8859-1',
      'wordwrap' => TRUE
    );

$this->load->library('email', $configs);
$this->email->initialize($configs);

$msg = '<html><body>';
$msg.= 'msg here';
$msg.= '</body></html>';

$this->email->set_newline("\r\n");
$this->email->subject('Career Form Filled');
$this->email->from($from,$full_name);
$this->email->reply_to(REPLY_TO);
$this->email->to('xxxx@gmail.com');
$this->email->message($msg);
$this->email->send();
$full_name='xxx';
$from=$email=info@manazelspecilists.com';
$configs=Array(
'协议'=>'smtp',
“smtp_主机”=>“mail.manazelspecialists.ae”,
“smtp_端口”=>587,
'smtp_用户'=>'support@manazelspecialists.ae',
'smtp_pass'=>'xxxx',
“邮件类型”=>“html”,
“字符集”=>“iso-8859-1”,
'wordwrap'=>TRUE
);
$this->load->library('email',$configs);
$this->email->initialize($configs);
$msg='';
$msg.='msg here';
$msg.='';
$this->email->set_newline(“\r\n”);
$this->email->subject('Career Form Filled');
$this->email->from($from,$full_name);
$this->email->reply\u to(reply\u to);
$this->email->to($this)xxxx@gmail.com');
$this->email->message($msg);
$this->email->send();
我收到这个错误:无法发送AUTH LOGIN命令。错误:
无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。

更改配置数组中的一行,然后重试

 $configs = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'ssl://mail.manazelspecialists.ae',//change here
      'smtp_port' => 587,
      'smtp_user' => 'support@manazelspecialists.ae',
      'smtp_pass' => 'xxxx',
      'mailtype' => 'html',
      'charset' => 'iso-8859-1',
      'wordwrap' => TRUE
    );

我认为代码没有问题。您需要确保设置邮件服务器的正确配置。

尝试将
smtp\u端口更改为25

$config = Array();

 $config['protocol']        = 'smtp';
 $config['smtp_host']       = 'mocha4004.mochahost.com';
 $config['smtp_port']       = '25';
 $config['smtp_user']       = 'ankits@iguru-india.com';
 $config['smtp_pass']       = 'ankit123';
 $config['mailtype']        = 'html';
 $config['charset']         = 'iso-8859-1';
 $config['wordwrap']        = TRUE;
你可以试试我的例子

public function __construct()
{
    parent::__construct();
    $this->load->library('email');
    $this->load->model('email_model');
}


public function emails()
{

    $data['emails']=$this->email_model->get_records_of_chats_with_clients();
    $this->load->view('templates/head', $data);
    $this->load->view('templates/header', $data);
    $this->load->view('email/view_emails', $data);
    $this->load->view('templates/footer');


}
public function create()
{
    $data['privileges'] = $this->email_model->get_privileges();

    $this->form_validation->set_rules('privilege', 'privilege', 'required');
    $this->form_validation->set_rules('from_name', 'from_name', 'required');
    $this->form_validation->set_rules('from_email', 'from_email', 'required');
    $this->form_validation->set_rules('to_email', 'to_email', 'required');
    $this->form_validation->set_rules('title', 'title', 'required');

    if($this->form_validation->run() === FALSE){
        $this->load->view('templates/head', $data);
        $this->load->view('templates/header', $data);
        $this->load->view('email/create_email', $data);
        $this->load->view('templates/footer');
    } else {
    $this->email_model->record_chats_with_clients();
    redirect('email/emails');
    }

}
public function kurti(){
    $data['privileges'] = $this->email_model->get_privileges();
    $email_to=$this->input->post('to_email');
    $name_input=$this->input->post('name');
    $name_session=$this->session->userdata('name');
    $title=$this->input->post('title');
    $message=$this->input->post('message');
    if(!isset($name_input)){
        $name=$name_session;
    } else{
        $name=$name_input;
    }

    $this->email->from('mantas@fastfood.lt', $name);
    $this->email->to($email_to);
    $this->email->subject($title);
    $this->email->message($message);
    $config = array(
        'protocol' => 'smtp',
        'smtp_host' => 'example.serveriai.lt',
        'smtp_port' => 587,
        'smtp_user' => 'mantas@fastfood.lt',
        'smtp_pass' => 'example',
        'mailtype'  => 'html',
        'charset'   => 'iso-8859-1'
    );
    $this->email->set_mailtype("html");
    $this->load->library('email', $config);

    $this->form_validation->set_rules('to_email', 'Gavėjo adresas', 'required');
    $this->form_validation->set_rules('title', 'Gavėjo žinutės tema', 'required');
    $this->form_validation->set_rules('message', 'Žinutė', 'required');

    if($this->form_validation->run() === FALSE){
        $this->load->view('templates/head');
        $this->load->view('templates/header');
        $this->load->view('email/index', $data);
        $this->load->view('templates/footer');
    } elseif ($this->email->send()) {
        $this->email_model->record_chats_with_clients($name);
        $message = "success";
        echo '
        <script type="text/javascript">alert(\''.$message.'\');
        window.location = \'/email/emails\';</script>';
    }
    else
    {
        if ($this->session->userdata('admin'=='1')){
            show_error($this->email->print_debugger());

        } else{
            $message = "error!";
            echo "<script type='text/javascript'>alert('$message');</script>";
        }

    }
}
public function\uuuu construct()
{
父项::_构造();
$this->load->library('email');
$this->load->model('email_model');
}
公共功能电子邮件()
{
$data['emails']=$this->email\u model->获取与客户聊天的记录();
$this->load->view('templates/head',$data);
$this->load->view('templates/header',$data);
$this->load->view('email/view_emails',$data);
$this->load->view('templates/footer');
}
公共函数create()
{
$data['privileges']=$this->email_model->get_privileges();
$this->form_validation->set_规则('privilege'、'privilege'、'required');
$this->form_validation->set_规则('from_name','from_name','required');
$this->form_validation->set_规则('from_email','from_email','required');
$this->form_validation->set_规则('to_email','to_email','required');
$this->form_validation->set_规则('title','title','required');
如果($this->form\u validation->run()==FALSE){
$this->load->view('templates/head',$data);
$this->load->view('templates/header',$data);
$this->load->view('email/create_email',$data);
$this->load->view('templates/footer');
}否则{
$this->email\u model->录制与客户的聊天记录();
重定向(“电子邮件”);
}
}
公共职能库提(){
$data['privileges']=$this->email_model->get_privileges();
$email_to=$this->input->post('to_email');
$name_input=$this->input->post('name');
$name_session=$this->session->userdata('name');
$title=$this->input->post('title');
$message=$this->input->post('message');
如果(!isset($name_input)){
$name=$name\u会话;
}否则{
$name=$name\u输入;
}
$this->email->from($this)mantas@fastfood.lt“,$name);
$this->email->to($email\u to);
$this->email->subject($title);
$this->email->message($message);
$config=array(
'协议'=>'smtp',
'smtp_主机'=>'示例.serveriai.lt',
“smtp_端口”=>587,
'smtp_用户'=>'mantas@fastfood.lt',
“smtp_pass”=>“示例”,
“邮件类型”=>“html”,
“字符集”=>“iso-8859-1”
);
$this->email->set_mailtype(“html”);
$this->load->library('email',$config);
$this->form_validation->set_规则('to_email'、'Gavėjo adresas'、'required');
$this->form_validation->set_rules('title','Gavėjožinutės tema','required');
$this->form_validation->set_规则('消息','输入','必需');
如果($this->form\u validation->run()==FALSE){
$this->load->view('templates/head');
$this->load->view('templates/header');
$this->load->view('email/index',$data);
$this->load->view('templates/footer');
}elseif($this->email->send()){
$this->email\u model->记录与客户的聊天($name);
$message=“成功”;
回声'
警报(\'.$message.'\');
window.location=\'/email/emails\';';
}
其他的
{
如果($this->session->userdata('admin'='1')){
显示_错误($this->email->print_debugger());
}否则{
$message=“error!”;
回显“警报('$message');”;
}
}
}

您是在本地主机上还是在live server上尝试此代码?我正在live server上尝试此代码,smtp.googlemail.com可能与@dev重复,Google Mail.com您将使用端口
'smtp_port'=>465
?是@himanshuPadhayayank you@anand Panday,现在可以工作了,它以垃圾邮件的形式出现,并且“mailtype”=>“html”不起作用。它发送原始电子邮件。