Jump to content


This topic is now archived and is closed to further replies.


Php mail function and which ports to use?

Recommended Posts

WARNING-I tried to be thorough, but you may be able to understand what I'm saying without having to read all this

I'm using php 5 and apache 1.3.31 I think. Anyway I bought a php book to help me learn this faster, and I've installed php mysql and apache exactly as they said and I have tested each one and each is working as it should.

    $to = "pretzelking@gmail.com";
    $sub = "SUBJECT";
    $msg = "This is where my message goes...";
    $mail = mail ( $to, $sub, $msg )
    or die( "Sorry - Didn't work right");
    echo("It worked");
I wrote this using an example from the book. The format for the mail fuction is:
mail( to, subject, message );
Now heres what I don't get. When I try localhost/mail.php (where it is saved) I get the die message.

So, I try running it through the php editor that I am using, i.e. PHP Designer 2006. It tells me to check the settings for SMTP and smtp_port in php.ini

I open up php.ini in the WINDOWS folder and here's what I have for SMTP and smtp_port:
SMTP = localhost
smtp_port = 25

Note that neither of these have a semi-colon in front of them (which would exclude them).

Another thing that raised a red flag in my mind is in my debug preferences in PHP Designer It has a little box that says localhost (I believe) and then next to it it says port
Under localhost I put the correct location for the apache htdocs folder and under port it automatically put 80 in their. I'm not sure if this should be 25 like my smtp_port setting is or whatever.

Anyway in I round-about way I would just like to know if smtp_port = 25 is ok, or if there is a way to check which port I should use. Also should my settings in debug mode in PHP Designer be 25, 80, or something else?

Thanks a lot for your time :-D

Share this post

Link to post
Share on other sites
I think a better question would be, do you have a mail server installed on your system. As SMTP is pointing at localhost, I would assume it is looking for a mailserver on your local machine to send the email through... If not, install one or point it to a mail server online somewhere.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.