Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2009, 07:38 PM
Registered User
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Class SimpleMail ( need help)

I copied the class.SimpleMail.php and mail_quick.php code from the Beginning
php5, apache,mysql web development book. It is not working on my yahoo site.

Here is the code. Please let me know why it is not working.

// this is class.SimpleMail.php
<?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;
echo $this->to
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;

}
}
}
?>

// this is mail_quick.php.

<?php
require 'class.SimpleMail.php';
$postcard = new SimpleMail();
if ($postcard->send("[email protected]",
"Quick message test",
"This is a test using SimpleMail::send!")) {
echo "Quick message sent successfully!";
}

?>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Class SimpleMail timType3 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 July 27th, 2008 05:56 PM
class SimpleMail timType3 Beginning PHP 1 September 5th, 2006 07:04 AM
SimpleMail class problems derrida BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 July 6th, 2006 05:52 AM
class.SimpleMail.php problem mrthis PHP Databases 2 December 28th, 2005 09:30 AM
How to include c# class and vb class in the .vbprj umeshayk VS.NET 2002/2003 2 January 9th, 2004 12:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.