Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 891
  • Last Modified:

PHP Equivalent to ASP .CreateMHTMLBody

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.
0
chetweewax
Asked:
chetweewax
  • 5
  • 4
  • 2
  • +3
1 Solution
 
Ashish PatelCommented:
in ASP there is no class for sending emails, you will have to purchase third party dll files or components to do that.
0
 
Ashish PatelCommented:
sorry please neglect my commnets. Apologies.
0
 
steelseth12Commented:
is php you would use the mail() function to send emails
Examples and documentation can be found here http://www.php.net/manual/en/function.mail.php

Or you could use a mailing class like phpmailer

http://phpmailer.codeworxtech.com/
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
nizsmoDeveloperCommented:
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):



<?php
 
require("class.phpmailer.php");
 
$mail = new PHPMailer();
 
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.example.com"; // SMTP server
 
$mail->From = "from@example.com";
$mail->AddAddress("myfriend@example.net");
 
$mail->Subject = "An HTML Message";
$mail->Body = "Hello, <b>my friend</b>! \n\n This message uses HTML entities!";
 
?>

Open in new window

0
 
effxCommented:
Try :
Function SendMail (Email_From, Email_To, Email_Subject, Email_Body, Email_Body_Type, Email_Password)
Email_Server = "mail.yourdomain.com"
	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("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	          .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Email_Server
	          .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Email_From
	          .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Email_Password 
	          .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
	          .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	          .Update
		End With
		objEmail.Send
	Set objEmail = Nothing
End If
SendMail = "Sent"
End Function

Open in new window

0
 
effxCommented:
Sorry ignore my comment, misread the question.
0
 
nplibCommented:
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.
0
 
steelseth12Commented:
objection
0
 
chetweewaxAuthor Commented:
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.

while($i<$rows)
{
$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: <me@email.com>' . "\r\n";
$headers .= "\r\n";
$to = mysql_result($resulta,$i,"looped email address");
$subject = "HTML email";
mail($to,$subject,$message,$headers);
echo "Sent mail Successfully to - " . mysql_result($result,$i,"looped email address") . "<br>";
$i++;
}
0
 
steelseth12Commented:
Question
" I have a page that sends an email and uses  .CreateMHTMLBody.  I am looking for a PHP equivalent if there is one"

 From http://www.php.net/manual/en/function.mail.php

Example#4 Sending HTML email
<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
 
// subject
$subject = 'Birthday Reminders for August';
 
// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';
 
// 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 <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
 
// Mail it
mail($to, $subject, $message, $headers);
?>

Open in new window

0
 
steelseth12Commented:
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.
0
 
chetweewaxAuthor Commented:
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)
0
 
nplibCommented:
correct me if I'm from, but CreateMHTMLBody("www.google.com") 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?
0
 
steelseth12Commented:
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

0
 
chetweewaxAuthor Commented:
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.
0
 
chetweewaxAuthor Commented:
Sorry for any confusion
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 4
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now