2017-01-03 26 views
-2

我已經觀看和閱讀所有視頻和相關的問題,這些問題將來自Gmail電子郵件「如何使用XAMPP的Gmail發送電子郵件 PHP ??」。它運行但在SENDMAIL.ini執行無法正常工作使用XAMPP

img Problem #1 的這張照片顯示,當我點擊確認按鈕,本地主機/ EX2/here.php或你的PHP文件的名稱將永久載入除非你點擊sendmail.exe的CMD的X按鈕..

當我點擊sendmail.exe的CMD的X按鈕,此消息將顯示在我的PHP文件img Problem #2

這是我的代碼從Gmail發送電子郵件:

<?php 

$message = "This message will directly POSTED to your GMAIL account"; 
$headers = "From: [email protected]"; 

if(mail('[email protected]', 'Example', $message, $headers)) 
{ 
    echo "Text message is sent to [email protected]<BR/>"; 
} 
else 
{ 
echo "Not Work.."; 
} 
?> 

**Much appreciate if you can help me to fix my problem** :)

+0

在大局觀,你有什麼想在這裏實現?這是個人愛好項目還是付費項目/工作?這是因爲使用'mail'中的內部版本發送電子郵件是所有人坦率地選擇最糟糕的選擇 –

回答

0

嗯...發送電子郵件,您需要先設置你的gmail的配置,如協議,SMTP端口等

我...我使用CodeIgnitor框架,這個代碼,我在我的控制器已添加:

public function send_mail() { 

    $config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.gmail.com', 
     'smtp_port' => 465, //or 587 
     'smtp_timeout' => 7, 
     'smtp_user' => '[email protected]', //your gmail account 
     'smtp_pass' => 'xxx', //your gmail password 
     'mailtype' => 'html', 
     'charset' => 'iso-8859-1', 
     'wordwrap' => TRUE, 
     'newline' => "\r\n" 
    ); 

     $name = $_POST["name"]; 
     $email = $_POST["email"]; 
     $message = $_POST["message"]; 
     $subject = $_POST["subject"]; 
     $phone = $_POST["phone"]; 
     $shipment_code = $_POST["shipment_code"]; 
     $array = "Phone No: ".$phone."<br>Email: ".$email."<br>Shipment Code: ".$shipment_code."<br>Message: ".$message; 

     //Load email library 
     $this->load->library('email', $config); 

     $this->email->from('[email protected]'); 
     $this->email->to('[email protected]'); 
     $this->email->cc($email); 
     $this->email->subject($subject); 
     $this->email->message($array); 

     //Send mail 
     if($this->email->send()) 
     $this->session->set_flashdata('email_sent',"<h2>Your email was sent successfully.</h2>"); 
     else 
     $this->session->set_flashdata('email_sent',"Error in sending Email."); 
     echo $this->email->print_debugger(); 
     $this->load->view('views_contactus'); 

} 

如果你想看到的視圖,然後訪問this

0

的php.ini

SMTP=smtp.gmail.com 
smtp_port=465 
sendmail_from = [email protected] 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

sendmail.ini

smtp_server=smtp.gmail.com 
smtp_port=465 
error_logfile=error.log 
debug_logfile=debug.log 
[email protected] 
auth_password=YOUR_MAIL_PASS 
[email protected] 

的php.ini 延長= php_openssl.dll