Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Html emails by php

Posted on 2010-09-23
6
Medium Priority
?
321 Views
Last Modified: 2012-05-10
Hi i have a question about php mail functions. I work allot with regular text. But not i want to send email with html code. I try allot in different way and gmail every time get massage as plain text. Can any one help me how i can make it.

The sample of working code will be better.
0
Comment
Question by:umaxim
[X]
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
6 Comments
 
LVL 6

Accepted Solution

by:
jkratzer earned 2000 total points
ID: 33749798
0
 
LVL 5

Expert Comment

by:Neil_Bradley
ID: 33750174
The code show below will send an email to the address in the "to" field. Basically you would POST the information from your html contact form to a php page containing the code below (just make sure your form  fields names  are "name",  "email", " phone" and "message".
<?php
$to = "youremail@yourdomain.com";
                        $subject = "Form Submission from Website";
 
                        $msg="Name: " . $_POST['name'] ."\n";
                        $msg.="Email: " . $_POST['email'] ."\n";
                        $msg.="Phone Number: " . $_POST['phone'] ."\n";
                        $msg.="Message: " . $_POST['message'] ."\n";
                        $headers = "From: " . $_POST['email'] . "\r\n" .
                        "Reply-To: ".$_POST['email'] . "\r\n" .
                        'X-Mailer: PHP/' . phpversion();
 
                        mail($to, $subject, $msg, $headers);
                        
                        ?>
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 33751112
You can use attached class (TemplateMailer.class.php) this way:

<?php
include('../TemplateMailer.class.php');

$template_folder = '../templates/';//where you store normal html files to email saved as file.tpl.html

$destmail='your@email.com';
$mailadres1=user@email.com;
$temp = new TemplateMailer();
$temp->preparemail($template_folder . 'name_of_your_file.tpl.html');
$sent = $temp->send($destmail, $mailadres1, "Email subject", '');

?>

Cheers
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!

 
LVL 31

Expert Comment

by:Marco Gasi
ID: 33751114
Oooops, forgot the file
TemplateMailer.class.zip
0
 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 33761562
I think that PHPMailer class is what you are looking for.

$mail->IsHTML(true);

Website: http://phpmailer.worxware.com/
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();

$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";

$mail->AddAddress("email@example.com");
$mail->Subject = "Test 1";

$mail->IsHTML(true);
$mail->Body = "<h1>Test 1 of PHPMailer html</h1><p>This is a test</p>";
$mail->AltBody="This is text only alternative body.";

$mail->Send();
?>

Open in new window

0
 
LVL 4

Expert Comment

by:spsenthil
ID: 33763295
As I also suggest for PHPMailer.

Use PHPMailer with authentication to send email and to avoid going to span.

$mail->IsHTML(true);
$mail->IsSMTP();
$mail->Host     = "mail.somethign.com";
$mail->Mailer   = "smtp";
$mail->SMTPAuth = "true";
$mail->Username = "*********";
$mail->Password = "******";
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

721 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