Page 1 of 1

Please Help!! Need to get mailserver working! *PHP's mail()

PostPosted: 26. May 2011 21:36
by mikealex2k11
I'm learning PHP/MySQL but I need to get mailserver working. I go to use the mail() command and I get this error...

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\php\report.php on line 27

I'm not sure exactly what that means. Any help would be highly appreciated, thanks!

Re: Please Help!! Need to get mailserver working! *PHP's mai

PostPosted: 26. May 2011 22:03
by mikealex2k11
I enabled SMTP on my router and changed the SMTP in php.ini to my IP address instead of localhost, but I still get this error.

Re: Please Help!! Need to get mailserver working! *PHP's mai

PostPosted: 26. May 2011 23:27
by taustin
To start with the obvious, you did start Mercury (the mail server program), didn't you?

Re: Please Help!! Need to get mailserver working! *PHP's mai

PostPosted: 27. June 2011 00:15
by JonB
mikealex:

UNLESS - you have a registered domain name to work with (where you can set an MX record) getting a MAILSERVER to work is a good-sized chore. Mercury is a full-blown (and buggy) Windows Mailserver. If you search on Mercury/Pegasus you will find this out. If you actaully NEED an SMTP server, consider using hMail. Its more straightforward, and simple to make work. I run it on two Windows 2003 production servers and have had zero problems in four years, with it delivering mail everyday 8)
http://www.hmailserver.com/index.php?page=welcome

A MAILSERVER is just that -- it sends AND receives mail usually across two or more protocols, i.e. SMTP and POP. There an also be support for IMAP and maybe a webmail interface. Creating one and making it secure is a good sized task, and has inherent risks; mainly that you will accidentally create an open mail relay - that spammers use to disguise their trail -- AND get your domain on a mail blacklist.

if all you want to do is have outbound mail sent from your test platform, you only need an MTA -- line the included 'fake sendmail' that comes with XAMPP. Its a functional replica of the Unix derived sendmail that is natove to Linux,

For PHP to 'sendmail' you actually only need an MTA (Mail Transfer Agent) You only need to fix the 'sendmail' (its an MTA) that come with XAMPP, to point to an SMTP server you have rights on. There are two parts to the solution, you have to tell PHP where to find the MTA. This is the actaul line form my php.ini [mail function] section

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

Then you have to edit the sendmail.ini (in \xampp\sendmail) to tell it what SMTP server and account to use, AND tell it what the default account will be.

here's a topic where I explained it:
viewtopic.php?f=16&t=42756&p=168406&hilit=sendmail+JonB#p168406


Good Luck
8)

Re: Please Help!! Need to get mailserver working! *PHP's mai

PostPosted: 27. June 2011 01:31
by Sharley
As pointed out by JonB, you do not need a full blown mail server like Mercury or hMailServer to send email from a php form - the included sendmail correctly configured is all you need.

These complex Mail servers are intended for small to medium Local Area Networks (can be commercial or home based networks of more than just a couple of users) with a must have registered domain name to provide a mail service for their users for sending (SMTP) and also receiving (POP) email not for simply sending emails using a PHP web form - most ISPs do not allow these servers anyway, without prior approval, as they are a constant headache for them because of their prolific use by spammers and malicious mail etc.


In XAMPP version 1.7.4 the sendmail scripts are very old, and quite different from those in version 1.7.3 (MSMTP renamed to sendmail to prevent confusion), and should be updated to enable the latest ability to send secure email from web forms etc. and here is a link to the issues found in 1.7.4 sendmail:
viewtopic.php?p=174086#p174086

In this older version that is included in 1.7.4 you will not be able to send secure email or access email servers that rely on TLS (SSL) GMail for example, where as in the new version mentioned in the link above and it's improved sendmaail.ini file you will have no such issues - works well, so please follow the links in the above topic.

I also notice that in the 1.7.5 beta version I have here, it still contains the old and very inadequate sendmail version that 1.7.4 has - yet another overlooked important inclusion.


On the 'MSMTP an SMTP client' subject found in XAMPP 1.7.3, you can also replace the fake sendmail SMTP client in XAMPP 1.7.4 with the ultra configurable MSMTP found here...

...read about it...
http://msmtp.sourceforge.net/
...download the latest zip version...
http://sourceforge.net/projects/msmtp/files/msmtp/
...it's free absolutely!

Re: Please Help!! Need to get mailserver working! *PHP's mai

PostPosted: 27. June 2011 01:53
by Sharley
power2010 wrote:What do you mean by this problem?
@ WilliL
Yet another new poster priming many unrelated forums ready for signature spam. :evil:
search.php?author_id=57844&sr=posts

These need reporting using the large exclamation mark button, as potential sig. spammers so that the spam catcher, steini, can keep his eye on them.

Re: Please Help!! Need to get mailserver working! *PHP's mai

PostPosted: 27. June 2011 02:46
by JonB
@ Sharley

I have not tried it, BUT I can't think of any reason a knowledgeable user couldn't simply replace the 1.7.4 sendmail with the one from 1.7.3. They are standalone executable programs with zero dependencies AFAIK.

OK, maybe I will do that test his week one evening :mrgreen:

8)

Re: Please Help!! Need to get mailserver working! *PHP's mai

PostPosted: 27. June 2011 02:56
by Sharley
JonB wrote:BUT I can't think of any reason a knowledgeable user couldn't simply replace the 1.7.4 sendmail with the one from 1.7.3
That is assuming this user still has a copy of 1.7.3 or downloads 1.7.3 from the file repository.

This knowledgeable user may also be able to use the 1.7.3 version as a template/example to use in 1.7.4 using the latest MSMTP version - I found the examples that Wiedmann included in the ini file were somewhat confusing and limited that really required the reading of the associated documentation to understand what it all means - there were many posts about the use of MSMTP and it's ini file content for some difficult implementations, IIRC all of which were solved.

It was quite sometime before we all realized that in 1.7.3 we were using MSMTP and not Fake Sendmail, it wasn't well announced, but the clue was found, as usual, in the readme_en.txt file.

The version of MSMTP in 1.7.3 is now old 1.4.19 October 24, 2009, the latest version 1.4.24 April 27, 2011 and is available from the link I provided.

By all means copy over the one from 1.7.3 but update the files using the latest version.


I found the latest version of fake sendmail version 32 (18 June 2011) with the SSL/TLS facility quite adequate for XAMPP and after renaming by making a Copy of the original sendmail folder it just extract with overwrite in to it's place - minus the source folder if not required, save the zip archive for future use.

Best wishes. :)