Hi,
I'm using fputs($sock......) to send data from a PHP form to the mailserver. It works good, apart from the fact that I have difficulties with the HTML codes and adding images to the mail.
I would like to create a table, with 3 rows, 1 column, where in the first cell there's an image, in the middle cell there's the contents which is variable and in the bottom cell there's info about (un)subscribing.
I tested a few things and created the following code, not very near to what I would like, though it's a start.
The $messageb does work and shows "klik hier" linked to "www.anastacia-newkirk.com", though any hyperlink in the $message fails.
Could you help me building the rest?
Thanks!
Marijn
$messagea="<br>*******************************";
$messageb="<a href=\"http://www.anastacia-newkirk.com\">klik hier</a>";
include("../../dbconnect.php");
$sql = "SELECT * FROM members WHERE newsletter='y' ORDER BY user ASC";
$result = @mysql_query($sql);
if (!$result){
die("Database error: " . mysql_error());
}
while ($row = mysql_fetch_array($result)) {
$email = $row["email"];
$mailserver="localhost";
$from="mailinglist@anastacia-newkirk.com";
$subject="ANASTACIA-NEWKIRK.COM :: NEWS :: $newsnr";
if (!$sock=fsockopen("$mailserver", 25)) die("The mailserver is currently down, please try again later");
fputs($sock,"HELO $mailserver\n");
fputs($sock,"Content-Transfer-Encoding: binary\n");
fputs($sock,"Mime-Version: 1.0\n");
fputs($sock,"MAIL FROM: $from\n");
fputs($sock,"RCPT TO: $email\n");
fputs($sock,"DATA\n");
fputs($sock,"From: $from\n");
fputs($sock,"Subject: $subject\n");
fputs($sock,"To: $email\n");
fputs($sock,"Content-Type: text/html\n");
fputs($sock,"$message");
fputs($sock,"$messagea");
fputs($sock,"$messageb");