2016-07-12 2 views
1

здесь деталиXAMPP отправить почту не работает PHP

[php.ini]

SMTP = smtp.gmail.com 
smtp_port = 465 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 
mail.add_x_header=Off 

[sendmail.ini]

smtp_server=smtp.gmail.com 
smtp_port=465 
smtp_ssl=ssl 
error_logfile=error.log 
debug_logfile=debug.log 
auth_username=[email]@gmail.com 
auth_password=[email password] 
pop3_server= 
pop3_username= 
pop3_password= 
force_sender=[email]@gmail.com 
force_recipient= 
hostname=smtp.gmail.com 



[mail function] 
    mail('[email]@gmail.com','sample mail','sample content','From: [email protected]'); 

Я проверил настройки SMTP правильно, но его все еще не работает, пожалуйста, предложите.

+1

показать нам ваш код php ... –

+0

, пожалуйста, проверьте его @ J.Zend i edit my question – mickey

+0

у вас возникло сообщение об ошибке? –

ответ

0

Вы должны настроить SMTP на сервере

Вы можете использовать Googles бесплатный SMTP-сервер Довольно легко установить слишком.

<?php 

$mail = new PHPMailer(true); 

//Send mail using gmail 
if($send_using_gmail){ 
    $mail->IsSMTP(); // telling the class to use SMTP 
    $mail->SMTPAuth = true; // enable SMTP authentication 
    $mail->SMTPSecure = "ssl"; // sets the prefix to the servier 
    $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server 
    $mail->Port = 465; // set the SMTP port for the GMAIL server 
    $mail->Username = "[email protected]"; // GMAIL username 
    $mail->Password = "your-gmail-password"; // GMAIL password 
} 

//Typical mail data 
$mail->AddAddress($email, $name); 
$mail->SetFrom($email_from, $name_from); 
$mail->Subject = "My Subject"; 
$mail->Body = "Mail contents"; 

try{ 
    $mail->Send(); 
    echo "Success!"; 
} catch(Exception $e){ 
    //Something went bad 
    echo "Fail :("; 
} 

?> 

Вы также можете попробовать ниже.

Вы можете отправлять почту с localhost с помощью пакета sendmail, пакет sendmail встроен в XAMPP. Поэтому, если вы используете XAMPP, вы можете легко отправлять почту с localhost.

, например, вы можете настроить C:\xampp\php\php.ini и c:\xampp\sendmail\sendmail.ini for gmail to send mail.

в C :\xampp\php\php.ini find extension=php_openssl.dll и удалите точку с запятой с начала этой линии, чтобы сделать SSL работает Gmail для локального хоста.

в файле php.ini найти [функция почты] и изменить

SMTP=smtp.gmail.com 
smtp_port=587 
sendmail_from = [email protected] 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 
Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with following code 

[sendmail] 

smtp_server=smtp.gmail.com 
smtp_port=587 
error_logfile=error.log 
debug_logfile=debug.log 
[email protected] 
auth_password=my-gmail-password 
[email protected] 

// Спецрассылки

[email protected] 
mail($mail, 'Subject', 'sample mail', 'From: [email protected]'); 
+0

по-прежнему не отправляет никакую почту и даже почту() функция не показывает никаких ошибок, пытаясь получить результат из последних двух дней @ user3651819 – mickey

+0

Я использую window8, есть ли проблемы с версией или sumthin else. – mickey

+0

Да, у меня была такая же проблема для Windows 8, она не могла заставить ее работать. Я использую код выше на win 7 – user3651819

0

Вы должны использовать PHPMailer вместо: скачать с here

скопировать PHPMailerAutoload.php из загруженного Zip папки & вставить в каталог, где вы ваш контактной страницы Затем вставьте следующий код в контактной страницы сценария:

<?php 
require 'PHPMailerAutoload.php'; 

$mail = new PHPMailer; 

//$mail->SMTPDebug = 3;        // Enable verbose debug output 

$mail->isSMTP();          // Set mailer to use SMTP 
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers 
$mail->SMTPAuth = true;        // Enable SMTP authentication 
$mail->Username = '[email protected]';     // SMTP username 
$mail->Password = 'secret';       // SMTP password 
$mail->SMTPSecure = 'tls';       // Enable TLS encryption, `ssl` also accepted 
$mail->Port = 587;         // TCP port to connect to 

$mail->setFrom('[email protected]', 'Mailer'); 
$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->addAttachment('/var/tmp/file.tar.gz');   // Add attachments 
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name 
$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'; 
} 

Do не забудьте изменить фиктивные значения

0

php.ini

[mail function] 
; For Win32 only. 
; http://php.net/smtp 
;SMTP=localhost 
; http://php.net/smtp-port 
;smtp_port=25 
sendmail_path = C:/xampp/sendmail/sendmail.exe -t 
; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
; http://php.net/sendmail-path 
;sendmail_path = 
; Force the addition of the specified parameters to be passed as extra parameters 
; to the sendmail binary. These parameters will always replace the value of 
; the 5th parameter to mail(). 
;mail.force_extra_parameters = 
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename 
mail.add_x_header=On 
; The path to a log file that will log all mail() calls. Log entries include 
; the full path of the script, line number, To address and headers. 
;mail.log = 
; Log mail to syslog (Event Log on Windows). 
;mail.log = syslog 

Работа для меня.