Jump to content

PHP newsletter help


madhead29

Recommended Posts

Hi everyone i was wondering if someone could please help me. I have a newsletter system that i use but at the moment its just text to send messages. What i want to do is enter a message into the message box and then it get sent to the user but alow have a design when the user views the email. But what i dont want is the box to be filled with html i want the box to just contain the text. I have tried sending a test newsletter using some html tags like ie <b>This is bold</b> but it actually shows the tags and doesnt put it in bold i wonder if this could be a problem even though i dont want any html in the text box i want the html in a separate area. Any help is greatly appreciated. Thanks. Below is php code. quickmessage.php is the part where the box is and class.SimpleMail.php is the backend part of quickmessage.php

 

quickmessage.php code:

 

<?php

require('config.php');

?>

<html>

<head>

<title>Quick Message</title>

<link href="styles.css" rel="stylesheet" type="text/css">

</head>

<body>

 

<form method="post" action="admin_transact.php">

 

<p align="center">Enter the message below to send to the Newsletter user.</p>

<p align="center">Choose Mailing List:<br />

<select name="ml_id">

<option value="all">All</option>

<?php

 

$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)

or die('Could not connect to MySQL database. ' . mysql_error());

 

mysql_select_db(SQL_DB, $conn);

 

$sql = "SELECT * FROM ml_lists ORDER BY listname";

$result = mysql_query($sql)

or die('Invalid query: ' . mysql_error());

 

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

echo " <option value=\"" . $row['ml_id'] . "\">" . $row['listname'] .

"</option>\n";

}

 

?>

</select>

</p>

<p align="center">Compose Message:</p>

 

<p align="center">

Subject:<br />

<input type="text" name="subject" />

</p>

 

<p align="center">

Message:<br />

<textarea name="msg" rows="10" cols="60"></textarea>

</p>

<p align="center">

<input type="submit" name="action" value="Send Message" />

</p>

</form>

 

<p align="center">

<a href="admin.php">Back to mailing list administration</a></p>

 

</body>

</html>

 

 

class.SimpleMail.php code:

 

<?php

 

class SimpleMail {

public $to = NULL;

public $cc = NULL;

public $bcc = NULL;

public $from = NULL;

public $subject = '';

public $body = '';

public $htmlbody = '';

public $send_text = TRUE;

public $send_html = FALSE;

private $message = '';

private $headers = '';

 

public function send($to = NULL,

$subject = NULL,

$message = NULL,

$headers = NULL) {

if (func_num_args() >= 3) {

$this->to = $to;

$this->subject = $subject;

$this->message = $message;

if ($headers) {

$this->headers = $headers;

}

 

} else {

 

if ($this->from) {

$this->headers .= "From: " . $this->from . "\r\n";

}

if ($this->cc) {

$this->headers .= "Cc: " . $this->cc . "\r\n";

}

if ($this->bcc) {

$this->headers .= "Bcc: " . $this->bcc . "\r\n";

}

 

if ($this->send_text and !$this->send_html) {

$this->message = $this->body;

} elseif ($this->send_html and !$this->send_text) {

$this->message = $this->htmlbody;

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

$this->headers .= "Content-type: text/html; " .

"charset=iso-8859-1\r\n";

} else {

$_boundary = "==MP_Bound_xyccr948x==";

 

$this->headers = "MIME-Version: 1.0\r\n";

$this->headers .= "Content-type: multipart/alternative; " .

"boundary=\"$_boundary\"\r\n";

 

$this->message = "This is a Multipart Message in " .

"MIME format\n";

$this->message .= "--$_boundary\n";

$this->message .= "Content-Type: text/plain; " .

"charset=\"iso-8859-1\"\n";

$this->message .= "Content-Transfer-Encoding: 7bit\n\n";

$this->message .= $this->body . "\n";

$this->message .= "--$_boundary\n";

$this->message .= "Content-type: text/html; " .

"charset=\"iso-8859-1\"\n";

$this->message .= "Content-Transfer-Encoding: 7bit\n\n";

$this->message .= $this->htmlbody . "\n";

$this->message .= "--$_boundary--";

}

}

 

if (!mail($this->to,$this->subject,$this->message,$this->headers)) {

throw new Exception('Sending mail failed.');

return FALSE;

} else {

return TRUE;

}

}

 

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/105331-php-newsletter-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.