如何从XAMPP localhost发送电子邮件

时间:2015-01-01 05:20:45

标签: javascript php mysql email mysqli

我正在尝试从localhost XAMPP发送电子邮件,我已更新所有必需的文件,但仍无法从localhost发送电子邮件。

的php.ini

sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"

sendmail.ini

smtp_port=587

auth_username=myemail@gmail.com
auth_password=mypassword

在所有这些更新之后,我创建了一个PHP文件mail.php来发送邮件,但它没有发送任何电子邮件。

            include 'connect.php';

            $subject = $_REQUEST['subject'] ; // Subject of your email
            $personal_email= "abc@hotmail.com";


            $message .= 'Name: ' . $_REQUEST['name'] . "<br>";
            $message .= $_REQUEST['product_type']. "<br>";
            $message .= $_REQUEST['message'];


            $subject_to_sender= "Confirmation";
            $message_to_sender = "Thanks for contacting us";



            $name=          $_REQUEST['name'];
            $email=         $_REQUEST['email'];
            $message=           $_REQUEST['message'];
            $product_type=      $_REQUEST['product_type'];
            $address=           $_REQUEST['address'];


    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= "From: " . $_REQUEST['email'] . "\r\n"; // Sender's E-mail
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";    



        if (@mail($email, $subject_to_sender, $message_to_sender, $headers))
        {
            mail($personal_email, $subject, $message, $headers);
       // Transfer the value 'sent' to ajax function for showing success message.
            echo 'sent';
            }

在发送按钮上,我还将所有数据发送到数据库,并将其成功插入数据库。

请指导我。

由于

0 个答案:

没有答案