HTML File with phpmailer

the mail() function

Moderators: macek, egami, gesf

vouillot
New php-forum User
New php-forum User
Posts: 4
Joined: Tue Jan 27, 2004 9:41 am

HTML File with phpmailer

Postby vouillot » Tue Jan 27, 2004 9:46 am

Hello,
I'd like to know how I can send a html file with phpmailer, not as attached file).
If I can't with phpmailer, what can I do ?

Thanks

:D

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

Postby gesf » 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]

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

html file

Postby ruturajv » 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: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Fri Mar 19, 2004 7:27 am

Yeh... that´s a great idea when using different mail templates!


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest

cron