Jump to content

HTML EMAIL


metalx

Recommended Posts

I don't know what the benefit of sending an Email with PHP would be, but to send an HTML email with formatting and text just:

 

1) Code a page of everything you want to send and format it the way you want it.

 

2) Ctrl + A to select everything on the page.

 

3) Ctrl + V to paste it into your email client. Make sure it's not in plain text editing when you paste it.

 

4) Send.

 

I hope that helps...a little?

Link to comment
Share on other sites

Why does no one understand this? OP, you mean using mail() to send HTML inside the subject?

 

<?php
//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.<img src=\"http://img.com/img.jpg\"/> <b> I am html! </b> ";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com\r\n MIME-Version: 1.0";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
echo $mail_sent ? "Mail sent" : "Mail failed";
?>

 

And that should allow you to send HTML in an e-mail, mime set.. messy but correct example.

Link to comment
Share on other sites

You can use mail class. I have attached the mail class file and copy below given code and set the values.

 

<?php
$nameto = "";
$emailto = "";
$emailalt = "";
include_once("class.phpmailer.php");
$Mail = new PHPMailer();                                           
$Mail->Mailer = "mail";                
$Mail->SetLanguage("en","");
$Mail->IsHTML(true);
$Mail->Priority = 3;
$Mail->Encoding = "8bit";
$Mail->CharSet = "iso-8859-1";
$Mail->From = "";
$Mail->FromName = "";
$Mail->Sender = "";
$Mail->WordWrap = 0;                 
$Mail->Body = "";
$Mail->Subject = "" ;
$Mail->AddAddress($emailto,$nameto);
$Mail->Send();
?>

 

[attachment deleted by admin]

Link to comment
Share on other sites

Thaks and i ment using mail() just as posted above..

 

And to add variables to it I only and $var where i want the variable to appear?

 

thanks

 

Yes, in the body of the message you can place variables or whatever you'd like, PHP will parse the variables for you and send the message, the client would see the HTML and the variable that PHP sent through the mail() function.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.