PHP Mailer

How do i add a file or html page as the body

Page 1 of 1

5 Replies - 2748 Views - Last Post: 12 June 2007 - 04:23 AM Rate Topic: -----

#1 matt-the-mash  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 122
  • Joined: 10-July 06

PHP Mailer

Posted 11 June 2007 - 08:19 AM

Hi chaps, i've not posted for a while due to other work priorities, but i now need a bit help/advice with this one.

I have a database of customers/email adressess and i have sorted the code to pull all of the address's from the database and send an email to each person.

The problem is, i cant work out how to add a text file, or html document as the body, without actually typing the content in the '$mailbody' or just creating a link to a text/html file.

Here is the mailer code i am using.

 
<?php

$emailaddress = "Sender detail";

MYSQL_CONNECT("localhost","user","pw");
mysql_select_db("db");
{
echo "connected to server!";
}
$query  = "SELECT email FROM mailinglist";
$result = MYSQL_QUERY($query)
	or die(mysql_error()); 

while($row = mysql_fetch_array($result)) { 


$email = $HTTP_POST_VARS[email];
$mailto = "$row[email]";
$mailsubj = "Email Test";
$mailhead = "From: $emailaddress\n";
reset ($HTTP_POST_VARS);
$mailbody = "MESSAGE:\n ";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key :$val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
}

?>



Any ideas? :D

Is This A Good Question/Topic? 0
  • +

Replies To: PHP Mailer

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 250
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: PHP Mailer

Posted 11 June 2007 - 04:05 PM

Sorry, do you want to add the file itself as an attachment, or the contents of the file as the body of the email?
Was This Post Helpful? 0
  • +
  • -

#3 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1949
  • View blog
  • Posts: 20,376
  • Joined: 17-March 01

Re: PHP Mailer

Posted 11 June 2007 - 05:23 PM

Thanks for asking that... as I read your post this morning at 6:00AM through one eye... that's the question I wanted to ask but didn't realize I needed to ask ;)
Was This Post Helpful? 0
  • +
  • -

#4 matt-the-mash  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 122
  • Joined: 10-July 06

Re: PHP Mailer

Posted 12 June 2007 - 12:19 AM

View PostAmadeus, on 11 Jun, 2007 - 04:05 PM, said:

Sorry, do you want to add the file itself as an attachment, or the contents of the file as the body of the email?


Sorry, i want to add the file as the body of the email.
Was This Post Helpful? 0
  • +
  • -

#5 Styx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 192
  • Joined: 04-March 07

Re: PHP Mailer

Posted 12 June 2007 - 12:32 AM

If you want to use an external file where you can replace markers with content or something, use file_get_contents() with the mailbody.

If all you want is plain text, that's all there is. But if you want to use html/css, you have use mime types. See this post or this tutorial.
Was This Post Helpful? 0
  • +
  • -

#6 matt-the-mash  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 122
  • Joined: 10-July 06

Re: PHP Mailer

Posted 12 June 2007 - 04:23 AM

Thanks for that info. Works a treat :D :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1