Need help in php to send automatically an Email.

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
Frenchdeveloper
Forum Newbie
Posts: 2
Joined: Wed Jun 01, 2005 1:07 pm
Location: France

Need help in php to send automatically an Email.

Post by Frenchdeveloper »

Hi,

Could somebody help me?

The problem is:


I woild like my PHP program to be able to send an Email with in the content of the body, a table whose rows are extracted from a MySQL database. To do this I have included php instructions inside a variable named $body containing the htlm + php codes.

It does not work so I would appreciate to knwo if somenoe have solved yet thsi kind of problem.

Thanks and regards

Eric
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Please post your mail code so far.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

a header to indicate to mail clients you're using html you will need.

add to your $body var you will need:
ex:

Code: Select all

$body = "Content-type: text/html;";
while($row=mysql_fetch_assoc($result)){
  $body .= "Column 1:".$row['colone']."<br>";
  $body .= "Column 2:".$row['coltwo']."<br>";
//etc
}

//now use the mail function to send it...**NOTE, you will need to add additional headers

mail($to,$subject,$body);
as mentioned, more headers you will need in your body tag.

recommend I do that you research mail()
Frenchdeveloper
Forum Newbie
Posts: 2
Joined: Wed Jun 01, 2005 1:07 pm
Location: France

THANK YOU VERY MUCH

Post by Frenchdeveloper »

Hi,

Thank you so much for your answer,I have not tried yet, I do it now but I am convinced that your answer is THE solution to the problem I was facing.

THANK YOU VERY MUCH.

Eric

:D
Post Reply