2016-07-12 4 views
1

hier sind die DetailsXAMPP senden Sie eine Mail nicht funktioniert 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]'); 

Ich habe smtp Einstellungen überprüft richtig, aber es funktioniert immer noch nicht bitte schlagen Sie vor.

+1

zeigen Sie uns Ihren PHP-Code ... –

+0

überprüfen Sie es bitte @ J.Zend ich bearbeite meine Frage – mickey

+0

hast du irgendeine Fehlermeldung erhalten? –

Antwort

0

Sie SMTP

Sie können auf Ihrem Server Ziemlich einfach verwenden Setup zu dem Googles Server frei SMTP konfigurieren müssen sie ändern.

<?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 :("; 
} 

?> 

Sie können auch unten versuchen.

Sie können Mail von localhost mit sendmail-Paket senden, sendmail-Paket ist in XAMPP inbuild. Wenn Sie also XAMPP verwenden, können Sie einfach Mail von localhost senden.

zum Beispiel können Sie konfigurieren C:\xampp\php\php.ini und c:\xampp\sendmail\sendmail.ini for gmail to send mail.

in C :\xampp\php\php.ini find extension=php_openssl.dll und entfernen Sie das Semikolon aus dem Anfang der Zeile SSL arbeiten für gmail für localhost zu machen.

in der php.ini-Datei [Mail-Funktion] finden und

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] 

// Mail-Funktion

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

immer noch keine Mail und sogar mail() -Funktion keinen Fehler zeigt, versuchen, das Ergebnis der letzten zwei Tage zu erhalten @ user3651819 – mickey

+0

Ich benutze window8, gibt es ein Problem der Version oder sumthin sonst. – mickey

+0

Ja, ich hatte das gleiche Problem auf Windows 8, konnte es nicht funktionieren. Ich verwende Code oben auf Gewinn 7 – user3651819

0

sollten Sie PHPMailer statt: es herunterladen von here

kopieren Sie die PHPMailerAutoload.php aus der heruntergeladenen Zip-Ordner & in Ihrem Verzeichnis einfügen, in dem Sie haben Ihre Kontakt Seite Dann wird die Paste folgender Code in Ihrer Kontaktseite Skript:

<?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 nicht vergessen, den Dummy-Wert

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 

für mich arbeiten ändern.