This topic is locked

How to send email as HTML

3/9/2007 6:26:15 AM
PHPRunner General questions
L
Lisa2006 author

Hi Everybody,
Can someone please help me.
In the past I used a product called FormsToGo to to create an online submission form that would eventually send the users entry to my email as HTML.

It is a fantasic product 10/10 .... took me 5 mins to get up and running.
However, to achieve just a simple send email to user as HTML is taking over a week???? Should i continue using this product????
My requirement is as follows:

I have created the following:
Table: _demotable

field: username

field: lastname

field: email

field: password

field: ID created bu PHPRunner
I have entered the following code into _demotable Events > EDIT PAGE > Before Record Updated
function BeforeEdit(&$values, $where)

{
$email="lisa@myemailprovider.co.uk";

$subject="Thank you for your response";
$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers = "From: ".$values["username"]." <".$values["email"].">\n ";
$label = "First Name Entered";

$message.=$label.": ".$values["firstname"]."\r\n";

$label = "Surname Entered";

$message.=$label.": ".$values["lastname"]."\r\n";
mail($email, $subject, $message, $headers);

return true;

}
This works!!! - it sends the the 'firstname' and 'lastname' to my email address. However, its NOT in HTML format.
As I'm new to php & PHPRunner, I do not know how to adjust my code to allow an HTML output.
As an example I would like to see $label = "First Name Entered"; - say in blue Bold Large text

and the result held in database $message.=$label.": ".$values["firstname"]."\r\n"; - say in green medium size text
Can anyone Help

Lisa

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=4778&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />

J
Jane 3/9/2007

Lisa,
your message isn't HTML text. You need to use your HTML in your $message.

For example to send firstname as blue bold text use following code:

[/quote]

$message.=[b]"<b><font color=blue>".$label.": ".$values["firstname"]."</font></b>\r\n";

[/quote]

L
Lisa2006 author 3/10/2007

Please HELP <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=16149&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
I have carried out the advised:
Replaced my code:

$message.=$label.": ".$values["firstname"]."\r\n";
With Jane's code:

$message.=[b]"<b><font color=blue>".$label.": ".$values["firstname"]."</font></b>\r\n";
Still does not WORK......
To simply things, i have striped out some of my code and added the red code as follows:
function BeforeEdit(&$values, $where)

{
//** Send email with new data ****

$email="lisa@myemailprovider.co.uk";

$message="";

$subject="Thank you for your reply";

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers = "From: ".$values["username"]." <".$values["email"].">\n ";
[color=#FF0000]$message = "<html><head></head>".

"<body>".

"<h1>Test message</h1>".

"</body>".

"</html>";
mail($email, $subject, $message, $headers);

return true;

}[/color]
When i build and run the project all that is sent to my email is plain text as follows in the body section:

<html><head></head><body><h1>Test message</h1></body></html>
Is there anybody that can help me
Thanks you in advance
Lisa

G
Greeham 2/8/2008

Sorry to dredge an old post up but this is still the case I am having real problems having my email sent as HTML. Have tried everything including looking at http://www.php.net/manual/en/function.mail.php which, to be honest, after following it doesn't work at all.
Can someone please help here as I have recently purchased and have my boss saying it can be that hard to configure?
Thanks,
Graham

kujox 2/8/2008

This is the function I use, (which looks a lot like yours)
$timestamp = date( "d-m-Y H:m:s"); // Time Declaration

$email = "chris@whereto.co.uk"; // Recipients Email Address

$from = "chris@wherefrom.co.uk";

$bcc = "chris@bcc.co.uk";

$ccc = "chris@ccc.co.uk";

$subject = "test";

$headers = "From: " . $from . "\n"; // Who the email was sent from

$headers .= "cc: " . $ccc . "\n"; // If you want to CC: someone the same mail

$headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // IMPORTANT: This is where the mail is declared to have HTML content

$headers .= "Reply-To: $email\n"; // Reply to address

$headers .= "X-Priority: 1\n"; // The priority of the mail

$headers .= "bcc: " . $bcc; // If you want to BCC: someone the same mail

// Send the Mail

mail($email, $subject, $messagehtml, $headers);
just put the mail you need to send in $messagehtml

G
Greeham 2/8/2008

Hi There,
Thanks for replying,
This is what I have,
================

$email="test@test.com";

$subject="Request";
$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers = "From: ".$values["engineer"]." <".$values["date"].">\n ";
$label = "Instrument";

$message.=$label.": ".$values["instrument"]."\r\n";

$label = "Date";

$message.=$label.": ".$values["date"]."\r\n";

$label = "Engineer";

$message.=$label.": ".$values["engineer"]."\r\n";

$label = "Customer";

$message.=$label.": ".$values["customer"]."\r\n";
mail($email, $subject, $message, $headers);

return true;
=============
The problem is, no matter where I try and put my html it just shows up as text....What I would like is for there to be a line break between Instrument and date and have the Instrument show in bold.....
Thanks again,
Graham

J
Jane 2/11/2008

Graham,
here is an error in your code:

...

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers.= "From: ".$values["engineer"]." <".$values["date"].">\n ";

...

G
Greeham 2/11/2008

Graham,

here is an error in your code:


Hi Jane,
Do you mean $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; should be $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; ?
Thanks,
Graham

J
Jane 2/11/2008

Graham,
please my changes in Bold:

...

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers.= "From: ".$values["engineer"]." <".$values["date"].">\n ";

...

G
Greeham 2/11/2008

Hi Jane,
Worked great, thanks again for the great support.
Graham

S
smcgo4 2/11/2008

Thank you as well, I needed this for my little project!
Cheers
Steve