Page 1 of 1

Simple Mail In PHP

Posted: Mon Dec 21, 2009 5:50 am
by arpitgadle
Dear All,
I am PHP newbie. I had installed XAMPP on my system and wants to send a test mail. I had done the following changes to php.ini

Code: Select all

 
[mail function]
; For Win32 only.
SMTP = localhost
;SMTP = 10.0.2.211
;smtp_port = 25
smtp_port = 80
 
; For Win32 only.
;sendmail_from = me@example.com
sendmail_from = arpit_gadle@yahoo.co.in
 
and here is the test mail php script

Code: Select all

 
<html>
    <head>
        <title>Email In PHP</title>
        <?
            //syntax for sending mail
            /*
                mail(to,subject,message,headers,parameters) 
            */
        ?>
    </head>
    <body>
        <center>
            <h1>Email In PHP</h1>
            <h4>
                <?
                    $to="gadle.arpit@gmail.com";
                    $subject="Test Mail";
                    $message="This is a test mail sent from application runnuing locally on XAMPP";
                    $from = "arpit_gadle@yahoo.co.in";
                    $headers = "From: $from";
                    if(mail($to,$subject,$message,$headers))
                    {
                        echo "Mail Sent";
                    }
                    else
                    {
                        echo "Mail Not Sent";
                    }
                ?>
            </h4>
        </center>
    </body>
</html
 
Any help is appreciated

Thanks
Arpit

Re: Simple Mail In PHP

Posted: Mon Dec 21, 2009 6:10 am
by oscardog
Surely the mail function will not run as it's commented out...?

Re: Simple Mail In PHP

Posted: Mon Dec 21, 2009 6:12 am
by arpitgadle
Dear Sir,
XAMPP is a web server for PHP. And to mention I had tested the same code with WAMP server also.

Re: Simple Mail In PHP

Posted: Mon Dec 21, 2009 6:13 am
by oscardog
arpitgadle wrote:Dear Sir,
XAMPP is a web server for PHP. And to mention I had tested the same code with WAMP server also.
Yeh I know I should learn to read more carefully ;)

I replied above anyway :)

Re: Simple Mail In PHP

Posted: Mon Dec 21, 2009 6:23 am
by arpitgadle
I had not commented any mail function. Could you just point out for me

Re: Simple Mail In PHP

Posted: Mon Dec 21, 2009 1:21 pm
by oscardog
arpitgadle wrote:I had not commented any mail function. Could you just point out for me
Don't worry, I just saw the part in the header but it was merely for reference :)

I'm clueless :)