无法使用PHP mail()发送电子邮件。您的服务器可能未配置为使用此方法发送邮件 [英] Unable to send email using PHP mail(). Your server might not be configured to send mail using this method

查看:152
本文介绍了无法使用PHP mail()发送电子邮件。您的服务器可能未配置为使用此方法发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用codeigniter框架发送邮件。但是它将引发错误无法使用PHP mail()发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。

i tried to send the mail using codeigniter framework.but it will raise the error "Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

From: "prakash t" <tprakashkce@gmail.com>
Return-Path: <tprakashkce@gmail.com>
Reply-To: "tprakashkce@gmail.com" <tprakashkce@gmail.com>
X-Sender: tprakashkce@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5aed4eed40506@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
=?UTF-8?Q?Test=20Mail?=
hai this my test mail


但没有用

这是mycode:

公共函数sendMail(){

public function sendMail(){

    $config = Array(
        'protocol' => 'mail',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 587,
        'smtp_user' => 'example@gmail.com',
        'smtp_pass' => '*********'
    );

我知道这是重复的问题。但是我没有找到解决问题的方法

I know it's duplicate question.but i didn't find solution for my question

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

    $this->email->set_newline("\r\n");
    $this->email->from('tprakashkce@gmail.com','prakash t');
    $this->email->to('tprakash11121996@gmail.com');
    $this->email->subject('Test Mail');
    $this->email->message('hai this my test mail');

    if($this->email->send()){
        echo "mail send succesfully";
    }
    else{
        show_error($this->email->print_debugger());
    }

}


推荐答案

您已经做对了,但是初始化邮件时遇到了问题

You are done all correct but you have issue on initialize the mail

只需更改此

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

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

您可以检查在此处进行详细说明。

这篇关于无法使用PHP mail()发送电子邮件。您的服务器可能未配置为使用此方法发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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