PHP Equivalent to ASP .CreateMHTMLBody

Posted on 2007-11-23
Last Modified: 2010-04-21
I am currenly converting an asp site to a php site to host on a different server.  I have a page that sends an email and uses  .CreateMHTMLBody.  I am looking for a PHP equivalent if there is one.
Question by:chetweewax
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +3
LVL 23

Expert Comment

by:Ashish Patel
ID: 20340007
in ASP there is no class for sending emails, you will have to purchase third party dll files or components to do that.
LVL 23

Expert Comment

by:Ashish Patel
ID: 20340011
sorry please neglect my commnets. Apologies.
LVL 20

Accepted Solution

steelseth12 earned 500 total points
ID: 20340065
is php you would use the mail() function to send emails
Examples and documentation can be found here

Or you could use a mailing class like phpmailer

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 21

Expert Comment

ID: 20340390
I suggest using PHPMailer as steelseth12 mentioned, it will be much easier for you to send html emails, just a simple html email example of possibly what you are looking for (using phpmailer):

$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = ""; // SMTP server
$mail->From = "";
$mail->Subject = "An HTML Message";
$mail->Body = "Hello, <b>my friend</b>! \n\n This message uses HTML entities!";

Open in new window

LVL 10

Expert Comment

ID: 20345882
Try :
Function SendMail (Email_From, Email_To, Email_Subject, Email_Body, Email_Body_Type, Email_Password)
Email_Server = ""
	Dim objEmail
	Set objEmail = CreateObject("CDO.Message")
		objEmail.From = Email_From
		objEmail.To = Email_To
		objEmail.Subject = Email_Subject
		objEmail.TextBody  = Email_Body
		objEmail.HTMLBody  = Email_Body
		With objEmail.Configuration.Fields
	          .Item("") = 2
	          .Item("") = Email_Server
	          .Item("") = Email_From
	          .Item("") = Email_Password 
	          .Item("") = 1
	          .Item("") = 25
		End With
	Set objEmail = Nothing
End If
SendMail = "Sent"
End Function

Open in new window

LVL 10

Expert Comment

ID: 20345886
Sorry ignore my comment, misread the question.
LVL 17

Expert Comment

ID: 20360125
I don't have a lot of experience with fread and fopen, but if you read the contents of a webpage, it should print the html coding into the body of the email using phpmailer.

Maybe some of the other experts-may have an idea on how to do such a thing.
LVL 20

Expert Comment

ID: 21266638

Author Comment

ID: 21266790
I figured this one out on my own.

steelseth12 your links, while they pertaned to the the mail subject, they were not the reference i was looking for.

I have rethought the process and now store the HTML in my database and send out my emails from there.

$message = mysql_result($result,0,"email");
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <>' . "\r\n";
$headers .= "\r\n";
$to = mysql_result($resulta,$i,"looped email address");
$subject = "HTML email";
echo "Sent mail Successfully to - " . mysql_result($result,$i,"looped email address") . "<br>";
LVL 20

Expert Comment

ID: 21266845
" I have a page that sends an email and uses  .CreateMHTMLBody.  I am looking for a PHP equivalent if there is one"


Example#4 Sending HTML email
// multiple recipients
$to  = '' . ', '; // note the comma
$to .= '';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
  <title>Birthday Reminders for August</title>
  <p>Here are the birthdays upcoming in August!</p>
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <>, Kelly <>' . "\r\n";
$headers .= 'From: Birthday Reminder <>' . "\r\n";
$headers .= 'Cc:' . "\r\n";
$headers .= 'Bcc:' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);

Open in new window

LVL 20

Expert Comment

ID: 21266874
I assume that answers the question .

If there was something you didnt understand, had follow up questions or anything alot all bothered you it is customary to ask, not wait 4 months without giving any feedback and marking the question to be deleted.

Author Comment

ID: 21267033
The .CreateMHTMLBody in classic asp creates the message of the email from a totally seperate server page.  Again the references you gave me did not pertain to this type of feature.  The HTML code must be placed directly into the php page in the references you sent me.

If you are looking for the points without answering the question that was asked then I am sorry, I don't feel it is right to do so.

(And you are right I should have responded sooner, but I needed to to get something in place quickly so I used the database)
LVL 17

Expert Comment

ID: 21267069
correct me if I'm from, but CreateMHTMLBody("") for example
would take the html coding and place it into a variable so you could essentially email someone the google page and they would see it in their email?
LVL 20

Expert Comment

ID: 21267131
Just a quick note, I have unlimited access to this website for the next of the year without earning a single point, so i neither need nor want your points.

It just is beyond annoying to  ask a question, in a hurry, not bother to reply to any other experts that came here to help you for free and come back 4 months later to delete the question because figured out another way to do it that is irrelevant to the original question


Author Comment

ID: 21267151
yes that is correct.  It does allow you to send query strings to the page and populate information (a persons name from a database for instance)

I am going to award you the points

I don't need to make enemies here, the question was old, I thought deleting it was the easy way to stop the emails about open questions.  PHP is a new challenge for me and I may need more help in the future.

Author Closing Comment

ID: 31410688
Sorry for any confusion

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question