Page 1 of 1

php mail not working with localhost

PostPosted: 04. March 2008 02:37
by BoratSagdiyev
I'm having the same problem many others are having:

Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini

Here is part of my php.ini:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

Is there something I need to fix here to be able to get my web form to email me?
I apologize if this has been answered before, I searched earlier posts but may not have understood the answer since I don't really understand mail servers. Thanks in advance.

Re: php mail not working with localhost

PostPosted: 04. March 2008 03:10
by Milligan

PostPosted: 04. March 2008 11:54
by Scory
If you supply a remote SMTP Server, be sure that no login is required for sending mails. Most (nearly every) provider do not offer SMTP without login.

You should not use the poor PHP mail() function, but use the phpmailer instead (download at phpmailer.sourceforge.net). This works without any needs to configure php.ini and it supports SMTP login as well as HTML mails, attachments and so on.

PostPosted: 04. March 2008 12:24
by Milligan

PostPosted: 04. March 2008 12:42
by Scory
Milligan wrote:No need to download anything, you can use the fake sendmail included with xampp and add your email login information in the sendmail.ini file.


Still not the best solution (same problem as Mercury Server etc.): if you use your own SMTP relay and send mails directly, many large email providers (like web.de and gmx.de) are blocking incoming mails from "private" IPs (for SPAM reasons).

I just tested that scenario on my home pc and had lot of troubles with GMX.

Regards
Scory

PostPosted: 04. March 2008 12:50
by Milligan

PostPosted: 04. March 2008 13:37
by Scory
It does not depend on YOUR configuration. It depends on GMX.

Maybe you have no experience with GMX.DE (or WEB.DE), as these are german mail providers. They won't accept mails from your local PC. No way.

PostPosted: 04. March 2008 14:16
by Milligan

PostPosted: 09. March 2008 01:07
by BoratSagdiyev
Thanks for responding. I changed the smtp_server to my isp's in the php.ini and sendmail.ini files. Unfortunately 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\emailMe.php on line 11

I don't know why it is trying to connect to localhost when I specified my isp's mailserver.

Is the smtp_server the only field I need to change?

PostPosted: 09. March 2008 01:22
by Milligan

PostPosted: 09. March 2008 04:06
by BoratSagdiyev
Thank you so much, it worked! I updated the wrong php.ini file. I'm impressed by your knowledge of xampp, would you care to share some of the links that helped you when you were learning this stuff?

Re: php mail not working with localhost

PostPosted: 22. December 2011 15:25
by Greekgig
what was the link? all i see excuse the irony but yeah all i see is blank

Re: php mail not working with localhost

PostPosted: 22. December 2011 15:35
by Sharley
This is a very old topic and would probably no longer be relevant anyway.

Perhaps you could start a new topic with your own mail issues so that we may be able to offer a solution.

Best wishes. :)