Wednesday 4 May 2011

Mail Function In PHP




Mail Function In PHP

By using this function we can send the mails from php application to destination email id. The arguments are “to address, subject, body, and collection of headers”.

*To send mails from one location to another location we have to use the “SMTP SERVER”.

*The default port number of SMTP server is 25. The fourth argument, We can place the multiple headers.

*The fourth argument, we can place the multiple headers. The separated between one header and another header is “\r\n”. 

The mail related headers are nothing but cc, bcc, from etc.


<?php
if(mail("abc@gmail.com",hi","hello",From:DanielPHP"))
echo "mail has been sent";
else
echo "not";
?>

By using the above script we can’t send mails from our system. Because system doesn’t contains mail server. By default every web server contains mail server. So just try this script in any web server. 

1 comment:

  1. i am unable to install XAMPP and MYSQL database. kindly tell me which one to install first whether mysql or xampp
    sir in my database i have 10 records... i want to display them in two columns (first colom contains 5 records,and second column contains 5 records)
    display first five records in one table td tag and remaining records in another td tag

    ReplyDelete