Simple Mail In PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arpitgadle
Forum Newbie
Posts: 3
Joined: Mon Dec 21, 2009 5:45 am

Simple Mail In PHP

Post 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
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: Simple Mail In PHP

Post by oscardog »

Surely the mail function will not run as it's commented out...?
Last edited by oscardog on Mon Dec 21, 2009 6:13 am, edited 1 time in total.
arpitgadle
Forum Newbie
Posts: 3
Joined: Mon Dec 21, 2009 5:45 am

Re: Simple Mail In PHP

Post by arpitgadle »

Dear Sir,
XAMPP is a web server for PHP. And to mention I had tested the same code with WAMP server also.
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: Simple Mail In PHP

Post 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 :)
arpitgadle
Forum Newbie
Posts: 3
Joined: Mon Dec 21, 2009 5:45 am

Re: Simple Mail In PHP

Post by arpitgadle »

I had not commented any mail function. Could you just point out for me
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: Simple Mail In PHP

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