2017-04-09 118 views
0

我試圖用數據發送郵件,發送郵件,但它不發送任何 ,這裏是我的功能嘗試使用笨

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上有人試圖破解我的郵件,然後我讓它不安全的訪問郵件,但仍然沒有錯誤,甚至郵件!那麼這裏有什麼錯誤?

回答

0

因爲你的機器可是沒有電子郵件服務器 如果你是在本地主機,您可以使用SMTP郵件

+0

沒有它的在線服務器,所以我如何使用在線服務器從送? –

+0

發件人怎麼樣?什麼是發件人值? –

+0

你能否檢查更新 –