Customizing a Simple Auto reply Email Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sliilvia
Forum Newbie
Posts: 3
Joined: Mon Sep 29, 2008 5:56 pm

Customizing a Simple Auto reply Email Problem

Post 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
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Customizing a Simple Auto reply Email Problem

Post by papa »

Well it's easy to incorporate HTML code so just include a stylesheet and you can do whatever you want.
sliilvia
Forum Newbie
Posts: 3
Joined: Mon Sep 29, 2008 5:56 pm

Re: Customizing a Simple Auto reply Email Problem

Post by sliilvia »

Sorry I am really new to this and I am unsure of how to do this. :(
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Customizing a Simple Auto reply Email Problem

Post 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>
";
 
sliilvia
Forum Newbie
Posts: 3
Joined: Mon Sep 29, 2008 5:56 pm

Re: Customizing a Simple Auto reply Email Problem

Post 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?
User avatar
The_Anomaly
Forum Contributor
Posts: 196
Joined: Fri Aug 08, 2008 4:56 pm
Location: Tirana, Albania

Re: Customizing a Simple Auto reply Email Problem

Post 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.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Customizing a Simple Auto reply Email Problem

Post 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.
Post Reply