diff --git a/core/email.class.php b/core/email.class.php new file mode 100644 index 00000000..a3e9f555 --- /dev/null +++ b/core/email.class.php @@ -0,0 +1,119 @@ +to = $to; + + $sub_prefix = $config->get_string("mail_sub"); + + if(!isset($sub_prefix)){ + $this->subject = $subject; + } + else{ + $this->subject = $sub_prefix." ".$subject; + } + + $this->style = $config->get_string("mail_style"); + + $this->header = html_escape($header); + $this->header_img = $config->get_string("mail_img"); + $this->sitename = $config->get_string("site_title"); + $this->sitedomain = make_http(make_link("")); + $this->siteemail = $config->get_string("site_email"); + $this->date = date("F j, Y"); + $this->body = $body; + $this->footer = $config->get_string("mail_fot"); + } + + public function send() { + $headers = "From: ".$this->sitename." <".$this->siteemail.">\r\n"; + $headers .= "Reply-To: ".$this->siteemail."\r\n"; + $headers .= "X-Mailer: PHP/" . phpversion(). "\r\n"; + $headers .= "errors-to: ".$this->siteemail."\r\n"; + $headers .= "Date: " . date(DATE_RFC2822); + $headers .= 'MIME-Version: 1.0' . "\r\n"; + $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; + $message = ' + + + + + + + + + + + +
+ + + + + + + + +
'.$this->sitename.' +
+ + + + + + + + + + +
+ +

+'.$this->header.'
+'.$this->date.'
+

+

'.$this->body.'

+

'.$this->footer.'

+
+ +This email was sent to you since you are a member of '.$this->sitename.'. To change your email preferences, visit your Account preferences.
+ +
+Contact us:
+'.$this->siteemail.'

+Copyright (C) '.$this->sitename.'
+
+ +
+ + + + '; + $sent = mail($this->to, $this->subject, $message, $headers); + if($sent){ + log_info("mail", "Sent message '$this->subject' to '$this->to'"); + } + else{ + log_info("mail", "Error sending message '$this->subject' to '$this->to'"); + } + + return $sent; + } +} +?> \ No newline at end of file diff --git a/ext/mail/banner.png b/ext/mail/banner.png new file mode 100644 index 00000000..08303fe5 Binary files /dev/null and b/ext/mail/banner.png differ diff --git a/ext/mail/mail.css b/ext/mail/mail.css new file mode 100644 index 00000000..34b8b3c3 --- /dev/null +++ b/ext/mail/mail.css @@ -0,0 +1,9 @@ +.headerTop { background-color:#FFCC66; border-top:0px solid #000000; border-bottom:1px solid #FFFFFF; text-align:center; } +.adminText { font-size:10px; color:#996600; line-height:200%; font-family:verdana; text-decoration:none; } +.headerBar { background-color:#FFFFFF; border-top:0px solid #333333; border-bottom:10px solid #FFFFFF; } +.title { font-size:20px; font-weight:bold; color:#CC6600; font-family:arial; line-height:110%; } +.subTitle { font-size:11px; font-weight:normal; color:#666666; font-style:italic; font-family:arial; } +.defaultText { font-size:12px; color:#000000; line-height:150%; font-family:trebuchet ms; } +.footerRow { background-color:#FFFFCC; border-top:10px solid #FFFFFF; } +.footerText { font-size:10px; color:#996600; line-height:100%; font-family:verdana; } +a { color:#FF6600; color:#FF6600; color:#FF6600; } \ No newline at end of file diff --git a/ext/mail/main.php b/ext/mail/main.php new file mode 100644 index 00000000..1a02c3a8 --- /dev/null +++ b/ext/mail/main.php @@ -0,0 +1,45 @@ + +* Link: http://seemslegit.com +* License: GPLv2 +* Description: Provides an interface for sending and receiving mail. +*/ + +class Mail extends SimpleExtension { + public function onSetupBuilding($event) { + $sb = new SetupBlock("Mailing Options"); + $sb->add_text_option("mail_sub", "
Subject prefix: "); + $sb->add_text_option("mail_img", "
Banner Image URL: "); + $sb->add_text_option("mail_style", "
Style URL: "); + $sb->add_longtext_option("mail_fot", "
Footer (Use HTML)"); + $sb->add_label("
Should measure 550x110px. Use an absolute URL"); + $event->panel->add_block($sb); + } + + public function onInitExt($event) { + global $config; + $config->set_default_string("mail_sub", $config->get_string("site_title")." - "); + $config->set_default_string("mail_img", make_http("ext/mail/banner.png")); + $config->set_default_string("mail_style", make_http("ext/mail/mail.css")); + $config->set_default_string("mail_fot", "".$config->get_string("site_title").""); + } +} +class MailTest extends SimpleExtension { + public function onPageRequest($event) { + if($event->page_matches("mail/test")) { + global $page; + $page->set_mode("data"); + echo "Alert: uncomment this page's code on /ext/mail/main.php starting on line 33, and change the email address. Make sure you're using a server with a domain, not localhost."; + /* + echo "Preparing to send message:
"; + echo "created new mail object. sending now... "; + $email = new Email("example@localhost.com", "hello", "hello world", "this is a test message."); + $email->send(); + echo "sent."; + */ + } + } +} +?> \ No newline at end of file