Hello friends, welcome to my new blog post send html email in php. In my previous few post I gave you some OpenCart tips. But today I will tell you how to send html email in php. PHP has a built in mail function by which we can sent mail to anybody from our server. But when we sent mail to someone we have to care full about our mail content as well as mail design. If we sent a mail with proper look and html design using php then we need to put some additional code to support html in our mail.

Lets bulid the code:

Sending HTML Email through PHP uses the exact same mail function as text email:



The last parameter, the headers, are optional for the function but required for sending HTML email, as this is where we are able to pass along the Content-Type declaration telling email clients to parse the email as HTML.

In fact, the headers area gives us the opportunity to do lots of important email functions. This is where we can set the From: and Reply To: settings if need be, as well as CC and BCC other recipients (Hey, a checkbox for CC’ing yourself would be a cool feature to add!). Here is the code used for the new and improved HTML-Sendin’ Website Change Request Form:

Now We Can Use HTML Tags

The message parameter (a big string we pass to the mail function with the body of our email), can now have HTML tags in it. For example:

Here is whole shebang, to create the table of data as shown above:

Send html email in phpr

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Send html email in php example
Tagged on: