How to configure XAMPP to send mail from localhost

2018-12-31 00:23发布

I am trying to send mail from localhost. but i am unable to send the mail from localhost so can anybody tell me that how to reconfigure my xampp to send mail from localhost

标签: php xampp
9条回答
孤独寂梦人
2楼-- · 2018-12-31 00:53

You have to define an SMTP server and a port for this. All except like sending mails from live hosts.

This is a useful link regarding this.

NB: The port should be unused. Please take care that, Some applications like Skype uses the default ports and there by prevents sending mail.

查看更多
深知你不懂我心
3楼-- · 2018-12-31 00:54

If you have an installed copy of xampp latest copy then check this link for complete documentation of sending emails through xampp. You must enable apache before you try to access the below link

http://localhost/dashboard/docs/send-mail.html

查看更多
泛滥B
4楼-- · 2018-12-31 00:58

In XAMPP v3.2.1 for testing purposes you can see the emails that the XAMPP sends in XAMPP/mailoutput. In my case on Windows 8 this did not require any additional configuration and was a simple solution to testing email

查看更多
看风景的人
5楼-- · 2018-12-31 00:58

just spent over an hour trying to make this work. for everybody having the same trouble with all the suggestions posted not working: you have to restart Apache in your XAMPP inrerface! just restarting XAMPP wont work!!

查看更多
低头抚发
6楼-- · 2018-12-31 01:08

You have to configure SMTP on your server. You can use G Suite SMTP by Google for free:

<?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 = "your-gmail-account@gmail.com"; // 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 :(";
}

?>

Read more about PHPMailer here.

查看更多
余生无你
7楼-- · 2018-12-31 01:09

Its very simple to send emails on localhost or local server

Note: I am using the test mail server software on Windows 7 64bit with Xampp installed

Just download test mail server tool and install according to the instruction given on its website Test Mail Server Tool

Now you need to change only two lines under php.ini file

  1. Find [mail function] and remove semi colon which is before ;smtp = localhost
  2. Put the semi colon before sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"

You don't need to change anything else, but if you still not getting emails than check for the SMTP port, the port number must be same.

The above method is for default settings provided by the Xampp software.

查看更多
登录 后发表回答