[英]can't send email with codeigniter
i try to send mail in codeigniter like this : 我尝试像这样在codeigniter中发送邮件:
public function send()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.googlemail.com',
'smtp_port' => 587,
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => 'mypass',
'newlin' => "\r\n"
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('myemail@gmail.com', 'Admin Re:Code');
$this->email->to('toanotheremail@gmail.com');
$this->email->subject('Percobaan email');
$this->email->message('Ini adalah email percobaan untuk Tutorial CodeIgniter: Mengirim Email via Gmail SMTP menggunakan Email Library CodeIgniter @ recodeku.blogspot.com');
if (!$this->email->send()) {
show_error($this->email->print_debugger());
}else{
echo 'Success to send email';
}
}
but i have some error : 但我有一些错误:
220 smtp.googlemail.com ESMTP g15sm4364297pgu.52 - gsmtp
220 smtp.googlemail.com ESMTP g15sm4364297pgu.52-gsmtp
hello: 250-smtp.googlemail.com at your service, [182.253.163.55]
您好:250-smtp.googlemail.com为您服务,[182.253.163.55]
250-SIZE 35882577
250尺寸35882577
250-8BITMIME
250-8BITMIME
250-STARTTLS
250-STARTTLS
250-ENHANCEDSTATUSCODES
250个增强的状态代码
250-PIPELINING
250管道
250-CHUNKING
250个
250 SMTPUTF8
250 SMTPUTF8
Failed to send AUTH LOGIN command.
无法发送AUTH LOGIN命令。 Error: 530 5.7.0 Must issue a STARTTLS command first.
错误:530 5.7.0必须首先发出STARTTLS命令。 g15sm4364297pgu.52 - gsmtp Unable to send email using PHP SMTP.
g15sm4364297pgu.52-gsmtp无法使用PHP SMTP发送电子邮件。 Your server might not be configured to send mail using this method.
您的服务器可能未配置为使用此方法发送邮件。
please help me. 请帮我。
change 更改
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com', # Change this
'smtp_crypto' => 'tls', # Add this
'smtp_port' => 587,
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => 'mypass',
'newlin' => "\r\n"
);
And you're not using PHPMailer. 而且您没有使用PHPMailer。 Seems you're using email class of CI
似乎您正在使用CI的电子邮件类别
require_once(APPPATH."third_party/phpmailer/PHPMailerAutoload.php");
$mail = new PHPMailer;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = "aaa@gmail.com";
$mail->Password = "aaa";
$mail->CharSet = 'UTF-8';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.