In this tutorial you will learn how to create your own PHP Web mailer. You will learn the necessary steps for creating an email account and making connections to the server protocols for sending and receiving email. You also will get a listing of PHP commands that you can use to customize the Web mailer to your specifications. Assuming you have a basic knowledge of PHP, let's begin.
First, we need to create an actual email account, which we will do by opening a URL for creating mail accounts. Mail accounts of course can be created manually through
Cpanel X. You just need to enter your own cpanel username, password, domain and skin, email domain and email quota.
Now that we have created the account, we need to make connections to the servers for sending and receiving mail. Let's begin with the server for sending mail, SMTP. You should stick with the
mail() function if you're building webmail only for your domain addresses. Otherwise, your mail very likely will end up marked as spam.
fsockopento connect to the server:
You may use the server IP as well as the domain name. If you need an encrypted connection, add a
ssl:\ prefix to server name. Don't forget that the default port number for these connections is different from the unencrypted one.
In order to track sent messages, we have to store them in a database. I suggest using one table with the following structure:
If your users send a great number of messages per day, consider partitioning the table for better performance.