Fun fact with 'sendmail.exe' when using 'mail' function in PHP

2.3k Views Asked by At

I've already set sendmail_path to the path of 'sendmail.exe', but PHP didn't send email. it requires mail server or something.

PHP said can't connect to localhost at port 25. The fun fact in the php.ini file is that above the path to 'sendmail.exe', stated "Unix only!????", but 'sendmail.exe' is Windows executable. [i believe the sendmail.exe i have in XAMPP is windows version of the Unix sendmail, so the comment in php.ini might not be at right place]

I'm just only sending email, not receiving email, so why do i need a mail server (like Mercury)? or the SMTP (the protocol) requires a server for both sending & receiving?

As per my thinking, we can just open the port (usually 25? 465?) of the destination server to send message to. Anything wrong in my procedure here and above?

Just can't find the details in similar Stackoverflow questions so i bring up this matter, please help me get enlightened.

1

There are 1 best solutions below

6
On BEST ANSWER

Only because you find a file called sendmail.exe on your computer it does not mean that PHP supports that specific binary out of the box.

From sendmail_path:

[...] This directive works also under Windows. If set, smtp, smtp_port and sendmail_from are ignored and the specified command is executed.

Double check that sendmail.exe on your disk is compatible with PHP.

Try:

sendmail_path = "X:\path\to\sendmail.exe -t"

I'm just only sending email, not receiving email, so why do i need a mail server (like Mercury)? or the SMTP (the protocol) requires a server for both sending & receiving?

You don't need to. It's only likely that the configuration you use with sendmail.exe (that's not the PHP configuration, look for sendmail.ini instead) that you have told sendmail.exe to use an SMTP server.

Either change that, and if sendmail.exe does not provide the feature you're looking for, replace sendmail.exe with something that matches your needs.

It's just that by default it actually makes sense to send emails. So why are you upset about a configuration that makes sense?

See also: