I am trying to send an email using PHP. This is an email with hundreds of lines of HTML code (in the email.html file). I do not want to write all the HTML in PHP. How can I do it? Is my method below correct? Any better alternative?
My code (PHP):
$email_text = file_get_contents('email.html'); $headers = "From: def@gmail.com "; mail(' abc@gmail.com ', 'Hello', $email_text, $headers);
My email file (email.html):
<html> <body> <a href="http://google.com">Hello</a> </body> </html>
My problem: I want to send an HTML letter in which the HTML content will be displayed. HTML content is taken from a file called email.html.
Note 1: I simplified the code above for clarity only. The source code has headers that will display the HTML correctly. Also, the source HTML file contains hundreds of lines and CSS styles. I just mentioned just a few lines to simplify.
Note 2: There are many duplicates of sending emails using PHP, but I could not find how to include a large HTML file in just one line of PHP code.
Sumit gupta
source share