过去3天我一直在努力解决这个问题并搜索了很多网站和stackoverflow问题,但似乎我的代码很完美,但仍然没有用。
function send_email(){
$this->load->library('email');
$config['protocol'] = "smtp";
$config['smtp_host'] = "mail.shadowmail.com.au";
$config['smtp_port'] = 587;
$config['smtp_timeout']='30';
$config['smtp_user'] = "my email id here "; //
$config['smtp_pass'] = "******";
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from("my email id here ", "Test");
$this->email->to("jack@gmail.com");
$this->email->subject("heading");
$this->email->message("heyyyyyyyyyyyy");
if($this->email->send()){
echo "done";
}else{echo "fail";
show_error($this->email->print_debugger());
}
}
我得到的错误
220 Sol1-SMEX01.shadowmail.sol1 Microsoft ESMTP MAIL Service ready at Thu, 18 Jan 2018 10:39:18 +1100
hello: 250-Sol1-SMEX01.shadowmail.sol1 Hello [1.136.213.103]
250-SIZE 41943040
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250 CHUNKING
Failed to send AUTH LOGIN command. Error: 504 5.7.4 Unrecognized authentication type
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Date: Thu, 18 Jan 2018 00:39:28 +0100
From: "Test" <my email id was here , i just replaced it with this text>
Return-Path: <my email id was here , i just replaced it with this text>
To: jack@gmail.com
Subject: =?UTF-8?Q?heading?=
Reply-To: <my email id was here , i just replaced it with this text>
User-Agent: CodeIgniter
X-Sender: my email id was here , i just replaced it with this text
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5a5fdeb00e005@example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
heyyyyyyyyyyyy
这可能是你的基本问题,但我已经尝试了最近3天仍然得到同样的错误。似乎代码还可以,可能是出了问题,我无法识别。 我的电子邮件ID和密码是正确的,我已多次登录以验证凭据是否正常工作。
答案 0 :(得分:1)
Codeigniter的电子邮件库似乎不支持除最基本,不安全的身份验证方法之外的所有内容,[LOGIN
,基本上是纯文本的,并且您的SMTP服务器仅支持实际的安全身份验证方法。 [GSSAPI
和NTLM
]
您需要:
LOGIN
STARTTLS
。在这些选项中,#1是你最好的选择,因为:
GSSAPI
或NTLM
的任何PHP电子邮件lib广告支持。TLDR:你必须对你的主人大吼大叫。
答案 1 :(得分:0)
不确定你是否还在努力解决这个问题但是
端口587用于TLS连接。 465用于SSL连接。
您需要在电子邮件配置库中设置一个额外的变量。
你也删除&#34; ssl://&#34;来自主机名。
所以你会为TLS连接配置这样:
$config['smtp_host'] = "mail.shadowmail.com.au";
$config['smtp_port'] = 587;
$config['smtp_crypto'] = "tls";
或者这是SSL连接:
$config['smtp_host'] = "mail.shadowmail.com.au";
$config['smtp_port'] = 465;
$config['smtp_crypto'] = "ssl";
话虽如此,我似乎发现TLS连接存在一些问题,过去几周突然无法正常工作。某些事情可能已在某处发生了变化。