尝试使用笨
问题描述:
我试图用数据发送邮件,发送邮件,但它不发送任何 ,这里是我的功能尝试使用笨
public function sendmail($response) {
$this->load->library('email');
$bcc="";
$this->email->from(EMAIL_FROM_EMAIL, EMAIL_FROM_NAME);
$this->email->to("[email protected]");
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 = '[email protected]'; // 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('[email protected]', '[email protected]');
$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
$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';
}
}
更新代码只是给我一个消息在我的Gmail上有人试图破解我的邮件,然后我让它不安全的访问邮件,但仍然没有错误,甚至邮件!那么这里有什么错误?
答
因为你的机器可是没有电子邮件服务器 如果你是在本地主机,您可以使用SMTP邮件
没有它的在线服务器,所以我如何使用在线服务器从送? –
发件人怎么样?什么是发件人值? –
你能否检查更新 –