Results 1 to 9 of 9

Thread: PHP Email mail()

  1. #1
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Email mail()

    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 :-)

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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")

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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 :-)
    Last edited by garywhw; 01-23-2007 at 01:58 AM. Reason: Add Signature

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by garywhw View Post
    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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

    </Edit>
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #9
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Cool, mates

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •