Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

HTML File with phpmailer

the mail() function

Moderators: macek, egami, gesf

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
vouillot
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue Jan 27, 2004 9:41 am

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
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

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
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

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

Yeh... that´s a great idea when using different mail templates!
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 6 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron