sendmail.exe -t works under Console but PHP mail() failed

Problems with the Windows version of XAMPP, questions, comments, and anything related.

sendmail.exe -t works under Console but PHP mail() failed

Postby jk123 » 02. April 2007 19:50

Hello everybody:

I'm having trouble using mail() on XAMPP1.6a PHP5. I am running
Windows server 2003 64bit. I have tested that sendmail.exe -t under
DOS, and it just worked fine. I could send mail by using
C:\xampp_path\sendmail\sendmail.exe -t < mymailfile.txt
;however, when I used mail() function to send simple email in my PHP script, its executed without any error messages but mail never sent. Also when I opened that mail PHP script, the DOS console is opened and closed right after. Was that console tried to displayed some error message to me?

[my mail function in C:/xampp_path/apache/bin/php.ini ]


Code: Select all
[mail function]
; For Win32 only.
;SMTP =
;smtp_port = 25

; For Win32 only.
;sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:/Program Files (x86)/xampp/sendmail/sendmail.exe -t"


[my sendmail.ini]

Code: Select all
; configuration for fake sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server
;smtp_server=localhost



smtp_server= smtp.webhostmailserver.com




; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=local

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

;error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

;debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines




auth_username=admin@mydomain.com
auth_password=mypasswd





; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines

;pop3_server=
;pop3_username=
;pop3_password=

; to force the sender to always be the following email address, uncomment and
; populate with a valid email address.  this will only affect the "MAIL FROM"
; command, it won't modify the "From: " header of the message content

;force_sender=me@localhost

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting.  you can manually set the ehlo/helo name if required

;hostname=localhost



Did anyone experience something like this?
Thanks for your help! appreciated!
...
jk123
 
Posts: 5
Joined: 01. April 2007 22:35
Location: NA

Postby Wiedmann » 02. April 2007 21:26

Code: Select all
error_logfile=error.log
debug_logfile=debug.log

If you enable these two logs, what happens?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby jk123 » 03. April 2007 16:59

Thanks for you help Wiedmann, I have tried to enable those two logs.
And I didn't see any error.log or debug.log files inside the sendmail folder. I take that means no errors at all. Am I right? I'm gona to try
it in windows 32bit. let see what's gona happen!


Wiedmann wrote:
Code: Select all
error_logfile=error.log
debug_logfile=debug.log

If you enable these two logs, what happens?
...
jk123
 
Posts: 5
Joined: 01. April 2007 22:35
Location: NA

Postby Wiedmann » 03. April 2007 17:09

I take that means no errors at all. Am I right?

No, no log means: PHP don't (can't) use this "sendmail.exe".

(In the debug.log, every access is logged, not only errors)

Code: Select all
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:/Program Files (x86)/xampp/sendmail/sendmail.exe -t"

Can you verify this setting in phpinfo()?

The path is valid? In cmd.exe:
Code: Select all
dir "C:\Program Files (x86)\xampp\sendmail\sendmail.exe"



A little testscript:
Code: Select all
<?php
    error_reporting(E_ALL);

    $to      = 'jane.doe@example.com';
    $subject = 'Testmail';
    $message = 'Hallo, dies ist ein Test.';
    $headers = 'From: John Doe <john.doe@example.com>';

    mail($to, $subject, $message, $headers);
?>

Any output? Something in Apache "error.log"?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby jk123 » 03. April 2007 22:38

Thank you again Wiedmann. I believe that the problem is
PHP could not interpret
sendmail_path ="C:/Program Files (x86)/xampp/sendmail/sendmail.exe -t"
correctly.

I found this error in apach/logs/error.log
'C:/Program' is not recognized as an internal or external command,
operable program or batch file.


After I move the sendmail folder to C: and set the sendmail_path to:
sendmail_path ="C:/sendmail/sendmail.exe -t"
it works now, but why the DOS console still showed up and closed right after?
Is it normal? Do you have any idea why that happened?

Thank you so much! I appreciated for you help!
...
jk123
 
Posts: 5
Joined: 01. April 2007 22:35
Location: NA

Postby Wiedmann » 04. April 2007 01:34

I found this error in apach/logs/error.log
Code: Select all
'C:/Program' is not recognized as an internal or external command,
operable program or batch file.

You have found a bug in PHP ;-)

After I move the sendmail folder to C: and set the sendmail_path to:

That's one solution. Another is, use the 8.3 name for the path. For example:
Code: Select all
sendmail_path = "C:\PROGRA~2\xampp\sendmail\sendmail.exe -t"


but why the DOS console still showed up and closed right after?

You don't start Apache as Windows service. In this case you have a visible command window.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby jk123 » 04. April 2007 16:27

Thank you so much wiedmann!
Finally I got everything running smoothly!
:D :D :D
...
jk123
 
Posts: 5
Joined: 01. April 2007 22:35
Location: NA

Postby Codesmith » 06. April 2007 04:53

Thanks, I spent hours trying to solve this today before someone pointed me to this post :)

Code: Select all
sendmail_path = "C:\PROGRA~2\xampp\sendmail\sendmail.exe -t"


Wouldn't work for me but

sendmail_path = "C:/sendmail/sendmail.exe -t"


Worked perfectly.

(I have 100% identical sendmail folders in both locations).
Codesmith
 
Posts: 101
Joined: 31. March 2007 21:11

Postby Wiedmann » 06. April 2007 10:29

Code: Select all
sendmail_path = "C:\PROGRA~2\xampp\sendmail\sendmail.exe -t"

Wouldn't work for me but

Well, IMHO you have not read two words in my post. "For example:". Because, I don't know the real 8.3 name for your "Program Files" folder. You must look with "dir /x" for the correct name in your Windows installation.

(In XP this is the most time "PROGRA~1")
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Codesmith » 06. April 2007 16:48

Sorry long day :) I quit testing possible solutions as soon I got mail() working. Four hours later I tried ~1 and it worked fine. :)

Is there an explanation about why there can't be a space in this particular path setting, or is it really just a strange and isolated bug?

Should I add a mental not, "if in doubt suspect a problem with spaces"?
Codesmith
 
Posts: 101
Joined: 31. March 2007 21:11

Postby Wiedmann » 06. April 2007 17:01

Is there an explanation about why there can't be a space in this particular path setting,

A path with a whitespace must be quoted. But PHP does not quote the path in the sendmail call.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 57 guests