Recent Comments

    mail() in PHP

    PHP allows you to send a mail from script. PHP has wide range of options in mail() function to use it.
    To send a mail(text) from script
    				$to = "";	
    				$subject = "My First Mail Script Demo from PHP";
    				$message = "Hello! This is a simple email message i tried from PHP.";
    				$from = "";
    				$headers = "From: $from";	
    				echo "Mail Sent.";
    The above code just sends a plain text to the mail specified as sender. In-order to send the mail with text/html, you can more parameters to the header, so that it”ll send”s an HTML mail. The following two lines tells our PHP script to send an HTML mail message instead of plain text mail. And let us add some more parameters to header like CC and Bcc, which add the CC and Bcc to our mail.
    			// To send the HTML mail we need to set the Content-type header.	
    			$headers = "MIME-Version: 1.0rn";
    			$headers .= "Content-type: text/html; charset=iso-8859-1rn";
    			$headers  .= "From: $fromrn";//options to send to CC and Bcc
    			$headers .= "Cc:";	
    			$headers .= "Bcc:"; 
    By using the header we can send the attachment also.
    In-addition to this, in PHP we have IMAP library to check the mails from your POP/IMAP server(s). The dll file php_imap.dll has the support for the IMAP function in PHP. This dll will be installed in ext folder under the PHP is in configured. This library can also be used to open streams to POP3 and NNTP servers, but some functions in this library and features are only available on IMAP servers. The following code will check the mail in your POP server”s Inbox folder and display the
    			//Open the POP3 Server's using the username and passowrd
    			$mbox = imap_open("{}INBOX", "username", "password");
    			$MC=imap_check($mbox); //Check the Mailbox using mbox handle	
    			//Fetch mbox''s message''s overview into an Array
    				$msg=$val->msgno; //Message #
    				$from=$val->from; //From address	
    				$date=$val->date; //Date Message sent
    				$subj=$val->subject; //Subject line of the mail	
    				echo "<tr><td align=''center''>$msg</td><td>$from</td><td>$date</td><td>$subj</td></tr>";	
    			//Close the handle
    Apart from the aboce taken parameters from the we can add many parameters into the overview handler. To check the above script in action click here

    Leave a Reply




    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>