Solved

Html emails by php

Posted on 2010-09-23
6
311 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
6 Comments
 
LVL 6

Accepted Solution

by:
jkratzer earned 500 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 30

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 30

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now