PHP-CI框架 发送邮件测试
2018-08-21 本文已影响0人
wangjunmech
//163邮箱测试
public function s3($mailadd){
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.163.com';
$config['smtp_user'] = 'wangjunmechdevise@163.com';
$config['smtp_pass'] = '密码';
$config['smtp_port'] = 25;
$config['smtp_timeout'] = 30;
$config['mailtype'] = 'text';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = PHP_EOL;
$config['crlf'] = "\r\n";
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('wangjunmechdevise@163.com','测试邮件的家伙');
$this->email->to($mailadd);
$this->email->subject('测试邮件PHPemail888'); // 发送标题
$this->email->message('Testing the email class.'); // 内容
echo $this->email->send();
$status = $this->email->print_debugger();
if($status){
echo "发送到{$mailadd}成功!<br>";
} else {
echo "发送到{$mailadd}失败败了,错误原因:!<br>";
}
}
//QQ邮箱测试
public function qq(){
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.qq.com';
$config['smtp_user'] = '账号@qq.com';
$config['smtp_pass'] = '授权码'; // 填写腾讯邮箱开启POP3/SMTP服务时的授权码,即核对密码正确 在邮箱设置 账号里面
$config['smtp_port'] = 465;
$config['smtp_timeout'] = 300;
$config['mailtype'] = 'text';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = PHP_EOL;
$config['crlf'] = "\r\n";
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('383933308@qq.com','王邮件');
$this->email->to('info@qualicrown.com,wangjundesign@126.com');
$this->email->subject('QQPHPemail'); // 发送标题
$this->email->message('Testing the email class.'); // 内容
$this->email->attach(base_url('sponde.stp'));//添加附件
echo $this->email->send();
$status = $this->email->print_debugger();
if($status){
echo '发送成功!';
} else {
echo '发送失败!';
}
}
//QC邮箱测试
public function qc(){
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtpout.secureserver.net';
$config['smtp_user'] = 'info@qualicrown.com';
$config['smtp_pass'] = '密码';
$config['smtp_port'] = 25;
$config['smtp_timeout'] = 300;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = PHP_EOL;
$config['crlf'] = "\r\n";
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('info@qualicrown.com','Q家伙');
$this->email->to('383933308@qq.com');
$this->email->subject('PHP-SMTP邮件M0157990.stp'); // 发送标题
$this->email->message('PHP-SMTP邮件00,Testing the email class.'); // 内容
$this->email->attach(base_url('M0157990.stp'));
//echo base_url('CSS选择器.doc');
echo $this->email->send();
$status = $this->email->print_debugger();
if($status){
echo '发送成功!';
} else {
echo '发送失败!';
}
}