简体   繁体   English

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

[英]SMTP error: 220 smtpauth.net4india.com ready Unable to send email using PHP SMTP. Your server might not be configured

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;
}

I have my domain and email registered to net4india.com, and hosting at godaddy. 我已经将域名和电子邮件注册到net4india.com,并在godaddy托管。

Using the above code i'm able to send mail from my localhost but not able to send from godaddy server. 使用上面的代码,我可以从本地主机发送邮件,但不能从Godaddy服务器发送邮件。

I have added mx records in godaddy hosting. 我在哥达主机中添加了MX记录。 Changed the routing to remote manager. 将路由更改为远程管理器。

I did lots of googling still ends up with no solution. 我做了很多谷歌搜索仍然没有解决的办法。

After doing lots of r&d i end up finding Sending mail through other providers isn't allowed on godaddy 经过大量的研发后,我最终发现在Godaddy上不允许通过其他提供商发送邮件

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;
}

old config: 旧配置:

$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'
    );

new config: 新配置:

$config = array(
            'protocol'  => 'mail',
            '_smtp_auth' => FALSE,
            'smtp_host' => 'localhost',
            'smtp_port' => 25,
            'newline'   => '\r\n',
            'mailtype'  => 'html',
            'charset'   => 'utf-8'
        );

I end up setting the _smtp_Auth to false, and using there server to send mails. 我最终将_smtp_Auth设置为false,然后使用那里的服务器发送邮件。

I even removed my username and password as i made the authentication to false. 当我将身份验证设置为false时,我甚至删除了用户名和密码。

changing port number to 25 as mentioned by godaddy. 如Godaddy所述将端口号更改为25。

This working solution for Codeigniter 3.x Codeigniter 3.x的此工作解决方案

Create email.php file in config folder this will auto load email configuration 在config文件夹中创建email.php文件,这将自动加载电子邮件配置

<?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; 

In your controller use 在您的控制器中使用

$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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 PHP SMTP 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP SMTP. Your server might not be configured to send mail using this methods 无法使用 PHP SMTP 发送 email。您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method Codeigniter 3 无法使用 PHP ZC2239A92BDE29F0A00F9173193CC2FE 发送 email。 您的服务器可能未配置为使用此方法发送邮件 - Codeigniter 3 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method CodeIgniter中的AWS SMTP邮件错误(无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。) - AWS SMTP mail error in CodeIgniter (Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.) 无法发送AUTH LOGIN命令。 错误:无法使用PHP SMTP发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Failed to send AUTH LOGIN command. Error: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method Codeigniter:您的服务器可能未配置为使用此方法发送邮件。 无法使用 PHP SMTP 发送电子邮件 - Codeigniter: Your server might not be configured to send mail using this method. Unable to send email using PHP SMTP 遇到错误无法使用 PHP mail() 发送 email。 您的服务器可能未配置为使用此方法发送邮件 - An Error Was Encountered Unable to send email using PHP mail(). Your server might not be configured to send mail using this method 无法使用 PHP mail() 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP mail(). Your server might not be configured to send mail using this method 遇到以下SMTP错误:0无法使用PHP SMTP发送电子邮件 - The following SMTP error was encountered: 0 Unable to send email using PHP SMTP 无法使用 PHP Sendmail 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM