我无法在codeigniter中使用mediatemple发送电子邮件。我已检查过电子邮件密码和smtp主机并且它们是正确的。
这是错误:
Severity: Notice
Message: fwrite() [function.fwrite]: send of 12 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host.
Filename: libraries/Email.php
Line Number: 1846
这是我的代码: 我用正确的smtp替换了sxxxxx.gridserver.com。
function _sendEmail($from,$fromname,$to,$subject,$message){
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'sxxxxx.gridserver.com',
'smtp_port' => 465,
'smtp_user' => 'noreply@mywebsite.com',
'smtp_pass' => 'mypass'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from($from,$fromname);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
}
任何帮助都将不胜感激。
编辑:我已使用端口25解决了此问题。
答案 0 :(得分:1)
public static void main(String[] args) {
Scanner lukija = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<>();
while (true) {
int red = Integer.valueOf(lukija.nextLine());
if (red == -1) {
break;
}
list.add(red);
}
System.out.println("");
// toteuta tänne toiminnallisuus luvun etsimiseen
int num = 0;
int index = 0;
int i = 0;
while (index <= list.size()) {
num = Integer.valueOf(lukija.nextLine());
System.out.println("What are we looking for? " + num);
i = list.get(index);
break;
}
i++;
index++;
System.out.println("number " + num + " is in index " + i);
}
}
将此添加到您的配置
答案 1 :(得分:0)
您需要初始化配置,请参阅the codeigniter documentation for the email class。
这是我的例子,效果很好......
function send_email($attributes) {
$this->load->library('email');
$this->email->set_newline("\r\n");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'host';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'user@smtp.com';
$config['smtp_from_name'] = 'FROM NAME';
$config['smtp_pass'] = 'XXX';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from($config['smtp_user'], $config['smtp_from_name']);
$this->email->to($attributes['to']);
$this->email->cc($attributes['cc']);
$this->email->bcc($attributes['cc']);
$this->email->subject($attributes['subject']);
$this->email->message($attributes['message']);
if($this->email->send()) {
return true;
} else {
return false;
}
}