Php 尝试使用codeIgniter发送邮件
我正在尝试使用发送包含数据的邮件,但它没有发送任何内容 这是我的函数Php 尝试使用codeIgniter发送邮件,php,codeigniter,api,email,Php,Codeigniter,Api,Email,我正在尝试使用发送包含数据的邮件,但它没有发送任何内容 这是我的函数 public function sendmail($response) { $this->load->library('email'); $bcc=""; $this->email->from(EMAIL_FROM_EMAIL, EMAIL_FROM_NAME); $this->email->to("dinacs110@gmail"); if (!empty
public function sendmail($response) {
$this->load->library('email');
$bcc="";
$this->email->from(EMAIL_FROM_EMAIL, EMAIL_FROM_NAME);
$this->email->to("dinacs110@gmail");
if (!empty($bcc)) {
$this->email->bcc($bcc);
}
$this->email->set_mailtype("html");
$this->email->subject("Hello Test");
$this->email->message("body");
$serverList = array('localhost', '127.0.0.1');
if (!in_array($_SERVER['HTTP_HOST'], $serverList)) {
$this->email->send();
}
}
我已进行了此更新,但仍然没有发送任何内容
public function sendmail($response){
require_once('phpmailer_/PHPMailerAutoload.php');
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'dinacs110@gmail.com'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('dinacs110@gmail.com', 'dinacs110@gmail.com');
$mail->addAddress('dinacs110@gmail.com', 'Joe User'); // Add a recipient
$mail->addAddress('dinacs110@gmail.com'); // Name is optional
$mail->addReplyTo('dinacs110@gmail.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
公共函数sendmail($response){
需要一次(“phpmailer\uu/phpmailerautoad.php”);
$mail=新的PHPMailer;
//$mail->SMTPDebug=3;//启用详细调试输出
$mail->isSMTP();//设置邮件程序以使用SMTP
$mail->Host='localhost';//指定主SMTP服务器和备份SMTP服务器
$mail->SMTPAuth=true;//启用SMTP身份验证
$mail->Username=dinacs110@gmail.com“;//SMTP用户名
$mail->Password='*****';//SMTP密码
$mail->SMTPSecure='tls';//启用tls加密,也接受'ssl'
$mail->Port=465;//要连接的TCP端口
$mail->setFrom('dinacs110@gmail.com', 'dinacs110@gmail.com');
$mail->addAddress('dinacs110@gmail.com“,”Joe User');//添加收件人
$mail->addAddress('dinacs110@gmail.com');//名称是可选的
$mail->addReplyTo('dinacs110@gmail.com","信息",;
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->isHTML(true);//将电子邮件格式设置为HTML
$mail->Subject='主题在这里';
$mail->Body='这是以粗体显示的HTML邮件正文!';
$mail->AltBody='这是非HTML邮件客户端的纯文本正文';
如果(!$mail->send()){
echo“无法发送消息”;
回显“邮件错误:”。$mail->ErrorInfo;
}否则{
回音“消息已发送”;
}
}
更新代码只是在我的gmail上给我一条消息,有人试图破解我的邮件,然后我就让它不安全地访问邮件,但仍然没有错误,甚至没有邮件!!那么这里的错误是什么呢?因为您的机器没有电子邮件服务器
如果您在localhost中,您可以使用smtp邮件不,这是联机服务器,那么我如何使用联机服务器进行发送?发件人如何?什么是发送方值??在长时间尝试访问它后,您能检查它给我的更新吗?数据库错误,那么这有什么问题:(