Page 1 of 1

Customizing a Simple Auto reply Email Problem

Posted: Mon Sep 29, 2008 6:03 pm
by sliilvia
Hi all, I am very new to Php and I have done some searching around and I cant find an answer to this. So I am hoping some kind person might be able to help me.

I have managed to get my auto reply working, but I want to be able to customize the actual email sent (fonts, colours, etc.) rather than just plain black and white text.

Here is my code so far:

Code: Select all

 
<?php
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];
 
 
 
if( $contact_name == true )
{
    $sender = $contact_email;
    $receiver = "myemailservercom";
    $client_ip = $_SERVER['REMOTE_ADDR'];
    $email_body = "Name: $contact_name \nEmail: $sender \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip \nFrom Industrial Placement Website";      
    $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
 
    if( mail( $receiver, "Flash Contact Form - $subject", $email_body, $extra ) ) 
    {
        echo "success=yes";
    }
    else
    {
        echo "success=no";
    }
}
// The Reply
$email = $_POST['email']; 
$header = "myemail.com";
$subject = 'Submission'; // change subject
$message = 'This is a confirmation that we have recieved your message, and we will be in contact with you soon regarding your enquiry. Thanks for your interest.'; //change text
mail($email, $subject, $message, 'From: '.$receiver.''); // send another one out
?>
 
I am trying to work out how I can customize my auto reply, but I am really struggling. Any help would be greatly appreciated.

Sliilvia

Re: Customizing a Simple Auto reply Email Problem

Posted: Tue Sep 30, 2008 2:15 am
by papa
Well it's easy to incorporate HTML code so just include a stylesheet and you can do whatever you want.

Re: Customizing a Simple Auto reply Email Problem

Posted: Tue Sep 30, 2008 3:02 am
by sliilvia
Sorry I am really new to this and I am unsure of how to do this. :(

Re: Customizing a Simple Auto reply Email Problem

Posted: Tue Sep 30, 2008 3:54 am
by papa
It's been awhile since I did something with e-mail. But what I did was just adding headers etc to my $message:

Code: Select all

 
$message="
<html>
<head>
<link to stylesheet>
</head>
<body>
hello mr
</body>
</html>
";
 

Re: Customizing a Simple Auto reply Email Problem

Posted: Tue Sep 30, 2008 4:05 am
by sliilvia
Thanks for your reply, I tried that and this is what the email generated looked like:

<html>
<head></head>
<body>
This is a confirmation that we have recieved your message, and we will be in contact with you soon regarding your enquiry.

Thanks for your interest.

Bailey


Industrial Placement Scheme.
</body>
</html>

How do I hide the tags, so they dont appear?

Re: Customizing a Simple Auto reply Email Problem

Posted: Tue Sep 30, 2008 4:23 am
by The_Anomaly
See this manual page, particularly Example #4: Sending HTML email.

It also seems like you don't know HTML and/or CSS. If this is the issue, check out w3schools, or just google around. There is a wealth of information available about designing.

Re: Customizing a Simple Auto reply Email Problem

Posted: Tue Sep 30, 2008 4:29 am
by papa
Sorry if I was a little too brief. See if this works:

Code: Select all

 
<head>
    
<link rel="stylesheet" type="text/css" href="http://mydomain.com/mystylesheet.css" />
 
</head>
 
<body>
 
bla
 
 
</body>
</html>
 
You should set content type, that's why it's read as plain text.

Was a little quick to post. You find all the info you need under the mail function url posted earlier.