首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SMTP错误: 220 smtpauth.net4india.com就绪,无法使用PHP发送电子邮件。您的服务器可能没有配置。

问SMTP错误: 220 smtpauth.net4india.com就绪,无法使用PHP发送电子邮件。您的服务器可能没有配置。
EN

Stack Overflow用户
提问于 2019-02-03 08:17:31
回答 2查看 397关注 0票数 0
代码语言:javascript
复制
public function send_mail()
{
    $this->CI->load->library('email');
    $config = array(
        'protocol'  => 'smtp',
        'smtp_host' => 'smtpauth.net4india.com',
        'smtp_port' => 587,
        'smtp_user' => 'xxxxx@my_domain.in',
        'smtp_pass' => 'xxxxxxxx',
        'newline'   => '\r\n',
        'mailtype'  => 'html',
        'charset'   => 'utf-8'
    );
    $this->CI->email->initialize($config);
    $this->CI->email->set_mailtype("html");
    $this->CI->email->set_newline("\r\n");
    $this->CI->email->from('info@my_domain.in', 'My Domain');
    $this->CI->email->to('xxxx@gmail.com');
    $this->CI->email->subject("Test Subject");
    $this->CI->email->message('Test Content');
    if(!$this->CI->email->send())
    {
        $error = $this->CI->email->print_debugger();
        echo "<pre>"; print_r($error); echo "</pre>"; exit;
        return false;
    }
    return true;
}

我有我的域名和电子邮件注册到net4india.com,并托管在高爸爸。

使用上面的代码,我可以从本地主机发送邮件,但不能从Go爹地服务器发送邮件。

我增加了mx记录在godaddy主机。将路由更改为远程管理器。

我做了很多谷歌搜索,结果还是没有解决方案。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-02-03 09:44:57

在做了大量的研发工作之后,我最终找到了godaddy不允许通过其他提供商发送邮件

代码语言:javascript
复制
public function send_mail()
{
    $this->CI->load->library('email');
    $config = array(
            'protocol'  => 'mail',
            '_smtp_auth' => FALSE,
            'smtp_host' => 'localhost',
            'smtp_port' => 25,
            'newline'   => '\r\n',
            'mailtype'  => 'html',
            'charset'   => 'utf-8'
        );
     $this->CI->email->initialize($config);
    $this->CI->email->set_mailtype("html");
    $this->CI->email->set_newline("\r\n");
    $this->CI->email->from('info@my_domain.in', 'My Domain');
    $this->CI->email->to('xxxx@gmail.com');
    $this->CI->email->subject("Test Subject");
    $this->CI->email->message('Test Content');
    if(!$this->CI->email->send())
    {
        $error = $this->CI->email->print_debugger();
        echo "<pre>"; print_r($error); echo "</pre>"; exit;
        return false;
    }
    return true;
}

旧配置:

代码语言:javascript
复制
$config = array(
        'protocol'  => 'smtp',
        'smtp_host' => 'smtpauth.net4india.com',
        'smtp_port' => 587,
        'smtp_user' => 'xxxxx@my_domain.in',
        'smtp_pass' => 'xxxxxxxx',
        'newline'   => '\r\n',
        'mailtype'  => 'html',
        'charset'   => 'utf-8'
    );

新配置:

代码语言:javascript
复制
$config = array(
            'protocol'  => 'mail',
            '_smtp_auth' => FALSE,
            'smtp_host' => 'localhost',
            'smtp_port' => 25,
            'newline'   => '\r\n',
            'mailtype'  => 'html',
            'charset'   => 'utf-8'
        );

最后,我将_smtp_Auth设置为false,并使用那里的服务器发送邮件。

我甚至删除了我的用户名和密码,因为我使身份验证为假。

将端口号更改为25,这是godaddy提到的。

票数 0
EN

Stack Overflow用户

发布于 2019-02-07 23:31:37

这个工作解决方案的代码点火器3.x

在配置文件夹中创建email.php文件,这将自动加载电子邮件配置

代码语言:javascript
复制
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$config['useragent'] = 'Codeigniter';
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://mail.domain.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'noreply@domain.com';
$config['smtp_pass'] = 'Password@123';
$config['charset'] = 'utf-8';
$config['newline'] = '\r\n';
$config['mailtype'] = 'html';
$config['validation'] = TRUE; 

在您的控制器中使用

代码语言:javascript
复制
$html = '<p>Hello</p>';
$html .= '<p>This is some demo email text.</p>';

                $this->load->library('email');
                $this->email->from('noreply@example.com', 'Label', 'returnpath@example.com');
                $this->email->to('recipient@example.com');
                $this->email->bcc('cc@example,com', 'anothercc@example.com');
                $this->email->subject('Subject For Mail');    
                $this->email->message($html);
                $this->email->send();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54501069

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档