Jump to content

send html mail to emailaddresses from database


andreas111

Recommended Posts

Hi, I'm new to php and I'm trying to fill in an online form and send that info to emailaddresses with the code below, but it doesn't work AT ALL

So I hope someone here could give me some guidelines to some success

 

This is my code

 

<?php

$to = 'name@msn.com';

$subject = 'Nieuwsbrief';

// message

$message = "<html>".

"<head>"."<title>Nieuwsbrief</title>".

"</head>"."<body>".

    "<center>".

    "<img src='http://www.xxxxxxxxxx.be/images/logo.png' style='padding: 30px 0 20px 0;' />".

    "</center>".

       

    "<center>".

    "<img src='http://www.xxxxxxxxxx.be/images/line.png' style='padding-bottom: 20px;' />".

    "</center>".

       

    "<h1 style='margin:10px 15px 5px 15px;font-family:Lucida Grande, Verdana, Arial, sans-serif;font-size:20px;color:#666;text-shadow:1px 1px 1px #cacaca;padding-bottom:5px;border-bottom: dotted 1px;'>".

        "{$_POST['txttitel']}".

    "</h1>".

       

    "<p>".

    "{$_POST['txtinhoud']}".

    "</p>".

."</body>"."</html>";

 

//get email list

 

//open database connection

$webspace='xxxxxxxxxx';

$username = "xxxxxxxxxx";

$password = "xxxxxxxxxx";

$database = "xxxxxxxxxx";

 

//connect to database

$link=mysql_connect($webspace,$username,$password);

@mysql_select_db($database) or die("<b>Unable to specified database</b>");

 

$query="SELECT fldemail FROM tblnieuwsbrief";

$result=mysql_query($query) or die('Error, query failed');

mysql_close($link);

 

$row=1;

$numrows=mysql_num_rows($result);

$bccfield="Bcc: ". mysql_result($result,0,"fldemail");

while($row<$numrows)

{

$email=mysql_result($result,$row,"fldemail");

$bccfield .= "," . $email; //seperate by comma

$row++;

}

$bccfield .= "\r\n";

 

// To send HTML mail, the Content-type header must be set

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= $bccfield;

 

// Mail it

mail($to, $subject, $message, $headers);

?>

 

thanks in advance

Andreas

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.