PDA

View Full Version : PHP Email mail()



garywhw
01-21-2007, 05:06 PM
Hi All :-)

I am new to PHP and are testing an email script which shows the error below. I am using localhost and didnt know how to fix the problem.

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 room-reservation-booking-form.php on line 124

----

While i uploaded it to the hosting server for testing, it said : successfully sent out. Yet, i didnt receive any email to both my gmail account and personal email accounts. Please advise what should i do to rectify the problem. Thanks :-)

BLiZZaRD
01-21-2007, 05:38 PM
First ensure you are using localhost as your server. localhost is the default setting for most DB scripts, and some servers don't use localhost as their DB server name. Some do though.

If yours does, try running it on port 2525, instead of just 25.

garywhw
01-22-2007, 05:11 PM
Thanks for your response. However, would appreciate if you would explain the meaning and steps of running it on port 2525 instead of 25, as i am a newbie with PHP.

cowguru2000
01-22-2007, 11:51 PM
Wait...

You might want to make sure the mail() function has a "From:" in it. This would be the last thing in the mail() function ... ex

mail(blah, blah, blah, "From: myemail@myhost.com")

thetestingsite
01-23-2007, 12:04 AM
First ensure you are using localhost as your server. localhost is the default setting for most DB scripts, and some servers don't use localhost as their DB server name. Some do though.

If yours does, try running it on port 2525, instead of just 25.

The message:



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 room-reservation-booking-form.php on line 124


has nothing to do with a DB server. Also, port 2525 would only work if their mail server's SMTP was set up for that port. First, check to make sure you have either a full blown mailserver with SMTP services enabled, or at least an SMTP service enabled on the server you are running these tests on. Then, check your php.ini file and verify the information matches that of your configuration. If someone else is running your server, tell them to do this.

Hope this helps.

garywhw
01-23-2007, 01:56 AM
Thanks for your advice :-)

Will check out whether i have a 'from' field to see if it works.

How do i check whether i have any SMTP service? I can send emails using Thunderbird, do you think i have SMTP to send emails too? If not, what should i do to setup a free SMTP service?

I am very new to php. Please bear with my queries. What do i need to check on php.ini and what configuration do i need to do? I assume a config for SMTP service, if i have one?

Thanks for your patience, mates :-)

thetestingsite
01-23-2007, 02:08 AM
How do i check whether i have any SMTP service? I can send emails using Thunderbird, do you think i have SMTP to send emails too?

Using Thunderbird is just an email client that connects to a POP3/IMAP/etc. server to get your emails, then to send them it connects to an SMTP server. If the server that you use for your emails is on the same server as the one you speak of in the first post, simply go into the php.ini file and look for Mail Functions or something to that effect.

Verify that it is set to the email server you use for your SMTP (outgoing server). If you are just running this off your home computer with a webserver environment, look into getting free mail server software (Google it).

Hope this helps.

Added Later: Look for (I believe it is called) C-Mail Server. It's a small mail server [perhaps a trial version] that supports only 5 users. This should be enough for your needs though.

BLiZZaRD
01-23-2007, 02:10 AM
You are trying to do this from your computer?

I thought you were doing t from a website.

Err.. you will need to install a mailserver at a minimum, Apache and PHP might be worthwhile as well.

Depending on what OS you are using will depend on which type of mailserver you should get.

Look on google for the right one :)

<Edit>

Test got to it faster than I :D

</Edit>

garywhw
01-23-2007, 02:21 AM
Cool, mates

I will google and see if i manage to get further from here :-)