我有一个奇怪的问题,并且不知道如何解决它。我的代码看起来完全正确,但系统尝试连接我自己的服务器(服务器的localhost)而不是正确的SMTP地址。
这是我的代码:
$config['protocol'] = "smtp";
$config['smtp_host'] = "smtp.mandrillapp.com";
$config['smtp_port'] = "587";
$config['smtp_user'] = "my@mailaddress.com";
$config['smtp_pass'] = "mypassword";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$CI -> email -> initialize($config);
$CI -> email -> from('mail@address');
$CI -> email -> reply_to('mail@address');
$CI -> email -> to($email);
$CI -> email -> subject('Some Topic');
$CI -> email -> message('Some message');
$CI -> email -> send();
当我运行这个脚本时,我得到了这个回复:
220-server.mydomain.com ESMTP Exim 4.86 #2 Sun, 08 Nov 2015 11:31:39 +0000 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
hello: 250-server.mydomain.com Hello li1430-121.members.linode.com [85.90.227.125]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
因此,它会出现登录错误,导致它尝试连接错误的服务器。我在网上进行了一项研究,但无法找到任何有关它的解决方案。
提前致谢。
答案 0 :(得分:0)
你完全错了。这意味着您使用电子邮件库代码的方式不正确。
$CI ->
$CI -> email ->
正确的代码就像这样
$config['protocol'] = "smtp";
$config['smtp_host'] = "smtp.mandrillapp.com";
$config['smtp_port'] = "587";
$config['smtp_user'] = "my@mailaddress.com";
$config['smtp_pass'] = "mypassword";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$this->email->initialize($config);
$this->email->from('mail@address');
$this->email->reply_to('mail@address');
$this->email->to($email);
$this->email->subject('Some Topic');
$this->email->message('Some message');
$this->email->send();