6

I cannot get XAMPP to send a dummy email from PHP using mailtodisk.exe (in other words, to save the output to the disk instead of really sending the mail). Instead, no matter what I do, the mails keep being sent normally. I am trying to set it to not really send the mails but to generate their output, using the mailtodisk.exe utility that comes with XAMPP.

My php.ini settings seem correct to me (although I do not know whether the sendmail_path needs to be in escaped quotes as the commented sendmail.exe's path is - in any case, I tried both and neither worked):

; sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

phpinfo() also shows that the settings are correct:

enter image description here

I tried setting the "sendmail_path" variable directly from the source code using ini_set(), I tried altering the "php.ini-production" and "php.ini-development" files as well (although pointlessly if you ask me), I even deleted the whole sendmail.exe containing folder completely, I did restart Apache every time I changed a setting, and it's still sending normal mails. My system is running Windows 10, XAMPP version is 3.2.2 and php version is 5.6.14.

What am I missing here?

EDIT: I neglected to mention that it used to work properly in the beginning, when I first installed XAMPP. Then at some point I needed to send an actual mail, so I changed the php.ini to use sendmail.exe, and I never managed to restore it ever since.

pazof
  • 944
  • 1
  • 12
  • 26
  • 1
    I believe that the possibility to use `sendmail_path` on Windows is a Xampp customisation, not part of official PHP. In any case, it requires `mail()` (if you use a decent mail library that speaks SMTP it'll bypass your local sendmail executable anyway). Is that how you're sending your messages? – Álvaro González Jun 28 '16 at 08:39
  • Try PHP's `PhpMailer` Library, by this you can setup your gmail account, and can send mails from localhost also, – HarisH Sharma Jun 28 '16 at 09:02
  • @ÁlvaroGonzález I am using PHPMailer with SMTP authentication to send my emails. That seems indeed to be the problem - I tried sending a mail using mail() and it worked. Going to further test this. – pazof Jun 28 '16 at 09:48
  • @ÁlvaroGonzález Sending a dummy email using mail() works. Sending a dummy mail using PHPMailer without SMTP authentication works. Sending a dummy mail using PHPMailer WITH SMTP authentication doesn't work - it sends the mail normally. So the SMTP authentication is the culprit. Do post it as an answer, so that I can give you the check mark. – pazof Jun 28 '16 at 09:53

3 Answers3

1

If you use PHPMailer to send your messages you need to ensure that it isn't using SMTP (if it opens a network connection to a remote server it won't use your local mailer). To do so you need to not call isSMTP() because the default method is to use built-in mail() function:

/**
 * Which method to use to send mail.
 * Options: "mail", "sendmail", or "smtp".
 * @type string
 */
public $Mailer = 'mail';
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
0

When I did this for my web server, I ran the mailtodisk.exe, and then in the root XAMPP folder was the mail folder and the emails were all in there.

I didn't have to do any config myself, it just worked.

Dakota Wagner
  • 117
  • 2
  • 15
  • It used to work properly for me as well when I first installed XAMPP. Then at some point I needed to send an actual mail, so I changed the php.ini to use sendmail.exe, and I never managed to restore it ever since. – pazof Jun 28 '16 at 08:35
  • I mean, I could always just reinstall XAMPP and it will probably work, I just want to find now what on earth is wrong with it. – pazof Jun 28 '16 at 08:54
0

Maybe try to configure external SMTP server to use it with mail for example using google gmail.

  • 1
    Sorry but this is the exact opposite of what's being asked. – Álvaro González Jun 28 '16 at 08:48
  • True that. Unusual though it may be, the problem isn't that I cannot send emails, the problem is that I DON'T want to send emails, I want to save the output to the disk instead. But it keeps sending the mails normally. (Some people would pray to be in my situation though :P) – pazof Jun 28 '16 at 08:58