I am a noob to php and databases. But I have an idea to perform mail operations on my own web server (i.e just by database operations), but I really don't have any idea of how to send mail to external websites like gmail. and also I look forward to making my own email-addresses like ex:-myownemail@localhost. I have searched google multiple times but I couldn't find any answer that I could understand. Can anyone tell me in simple words on how to do this?
First you need to have a webhost, grab a free one for testing purposes which supports mail function. Then after you are done setting up your host, try the following.
To send a mail, since you don't care if it goes to spam, use this simple php code:
<?php
$to = "xyz@somedomain.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:abc@somedomain.com \r\n";
$header = "Cc:afgh@somedomain.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>
If you just want to read mails using PHP, PHP has native functions to talk to IMAP, NNTP and POP mailboxes.