php mail()给我一个“没有磁盘”的错误

php mail()给我一个“没有磁盘”的错误

问题描述:

Hey I am trying to send an email from a php script. When I try to do so, I get a pop up box that is titled "mailtodisk.exe - No Disk". In the body of the error message, it says, "There is no disk in the drive. Please insert a disk into drive \Device\Harddisk1\DR1".

I have tried to figure this out but to no avail. I am doing this from localhost.

Here is my script that is supposed to send the email:

<?php       
$to = $_POST['email1'];
$subject = "Test mail";
$message = "I just sent you an email!";
$from = "ULSRL@louisiana.edu";
$headers = "From:" . $from;

if( mail($to, $subject, $message, $headers) )
{
    echo ("Mail Sent.");
}
else
{
    echo ("Mail could not be sent!");
}
?>

Any help is greatly appreciated! Thanks :)

I am guessing you are using XAMPP?

If so you will need to modify the php.ini located in your XAMPP installion, look for the following lines:

; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
sendmail_path = "C:\mailtodisk\mailtodisk.exe"

mail cannot be delivered in PHP even SMTP server is running and PHP mail() returns true

This should also help: http://blog.joergboesche.de/xampp-sendmail-php-mailversand-fuer-windows-konfigurieren#xampp_180_sendmail

You are trying this solution in Localhost. So you can get this error. Try in live work. You will definitely succeed.

For XAMPP, I have the same message it shows about 4 times providing options

{cancel}, {try again}, {continue}

No matter what I choose it replied 4 times and instead of showing the next page it showed the blank page.

My XAMPP version saves emails to the C:\xampp\mailoutput and this part was working.

What I did was: I commented out the following line is PHP.ini

 ;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

Now it does not save the files in C:\xampp\mailoutput

BUT it does not give me this annoying error and the next page loads fine.

Root cause of the problem is that mailtodisk.exe tries to reach non existing drive on your Windows machine, which cause this annoying message. This can be considered as a bug in mailtodisk actually, so you can simply don't use it as other replies here suggest.

This problem is caused usually because of USB sockets attached to your computer, for example for reading SD cards, which are currently empty.

If you prefer walking on the wild side, you can tweak your registry and suppress this message. See video demonstration here https://www.youtube.com/watch?v=Aj7-pLaAq2c