HTML File with phpmailer

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Thu Mar 11, 2004 5:51 am

You can do something like this:

HTML form:

Code: Select all

<form name="form1" method="post" action="sendmail.php">
Name: <input name="name" type="text" value=""><br />
Email: <input type="text" name="email" value=""><br />
Homepage: <input name="url" type="text" value="http://"><br />
Subject: <input name="subject" type="text" value=""><br />
Message: <textarea name="message" cols="40" rows="9" wrap="VIRTUAL"></textarea>
</form>


Sendmail.php:
[php]<?php

$name = $_GET['name'];
$email = $_GET['email'];
$url = $_GET['url'];
$subject = $_GET['subject'];
$message = $_GET['message'];

$to = $_GET['name'] . ' <' . $_GET['email'] . '>';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Yoursite <root@yoursite.com>\r\n";

$error = "Error sending message!";
$success = "Message sent succesfuly!";

$HTMLmessage = '
<html>
<head>
<title>' .$subject. '</title>
</head>
<body>
<table>
<tr>
<td>
From: ' .$name. '
Email: ' .$email. '
Website: ' .$url. '
Message: ' .$message. '
</td>
</tr>
<tr>
<td>Cool ;)</td>
</tr>
</table>
</body>
</html>';

function send(){
$send = mail($to, $subject, $HTMLmessage, $headers);
}

if(!$send)? print $error : print $success;
?>[/php]
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1279
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Fri Mar 19, 2004 5:44 am

just in the body part...

using fread, read the contents of the html file, and then assign the contents as the value to the body

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Fri Mar 19, 2004 7:27 am

Yeh... that´s a great idea when using different mail templates!
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest