26 Eylül 2007 Çarşamba

PHP SMTP Authentication: send an email through an authenticated SMTP server

Author: Matthew R. Miller, http://www.bytemycode.com/snippets/snippet/223/


<?php
function mymail($to,$subject,$message,$headers)
{
// set as global variable
global $GLOBAL;
// get From address
if ( preg_match("/From:.*?[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+.*/", $headers, $froms) ) {
preg_match("/[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+/", $froms[0], $fromarr);
$from = $fromarr[0];
}
// Open an SMTP connection
$cp = fsockopen ($GLOBAL["SMTP_SERVER"], $GLOBAL["SMTP_PORT"], &$errno, &$errstr, 1);
if (!$cp)
return "Failed to even make a connection";
$res=fgets($cp,256);
if(substr($res,0,3) != "220") return "Failed to connect";
// Say hello...
fputs($cp, "HELO ".$GLOBAL["SMTP_SERVER"]."\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "250") return "Failed to Introduce";
// perform authentication
fputs($cp, "auth login\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "334") return "Failed to Initiate Authentication";
fputs($cp, base64_encode($GLOBAL["SMTP_USERNAME"])."\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "334") return "Failed to Provide Username for Authentication";
fputs($cp, base64_encode($GLOBAL["SMTP_PASSWORD"])."\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "235") return "Failed to Authenticate";
// Mail from...
fputs($cp, "MAIL FROM: <$from>\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "250") return "MAIL FROM failed";
// Rcpt to...
fputs($cp, "RCPT TO: <$to>\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "250") return "RCPT TO failed";
// Data...
fputs($cp, "DATA\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "354") return "DATA failed";
// Send To:, From:, Subject:, other headers, blank line, message, and finish
// with a period on its own line (for end of message)
fputs($cp, "To: $to\r\nFrom: $from\r\nSubject: $subject\r\n$headers\r\n\r\n$message\r\n.\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "250") return "Message Body Failed";
// ...And time to quit...
fputs($cp,"QUIT\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "221") return "QUIT failed";
return true;
}
?>


Extracts all email adresses from a given string, and returns them as array

Author: Jonas John, http://codedump.jonasjohn.de/

<?php
/*
** Function: extract_emails (PHP)
** Desc: This function extracts all E-Mail adresses from a given string, and returns them as array.
** Author: Jonas John
*/

function extract_emails($str)
{
// This regular expression extracts all emails from
// a string:
$regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
preg_match_all($regexp, $str, $m);
return isset($m[0]) ? $m[0] : array();
}
?>


Email address validator

Author: Tobias Ratschiller & izzy, http://www.zend.com/tips/tips.php?id=224&single=1

<?php

/*
Original script by Tobias Ratschiller.
* top level domain must have at least 2 chars
* there can be more than one dot in the address
*/

function is_email($address) {
$rc1 = (ereg('^[-!#$%&'*+./0-9=?A-Z^_`a-z{}~]+'.
'@'.
'[-!#$%&'*+\/0-9=?A-Z^_`a-z{}~]+.'.
'[-!#$%&'*+\./0-9=?A-Z^_`a-z{}~]+$',
$address));
$rc2 = (preg_match('/.+.ww+$/',$address));
return ($rc1 && $rc2);
}
?>


Emailer Class

author: edolecki, http://www.bigbold.com/snippets/tag/php/6

<?php
import mx.events.EventDispatcher;
import mx.utils.Delegate;
class Emailer {
// required for EventDispatcher:
public var addEventListener:Function;
public var removeEventListener:Function;
private var dispatchEvent:Function;

// use to communicate with php script
private var _lv:LoadVars;
// holds address of sender
private var _sentFrom:String;
// constructor
public function Emailer() {
EventDispatcher.initialize(this);
_lv = new LoadVars();
}
//
private function dataReceived(dataxfer_ok:Boolean):Void {
// if some problem with loadVars transfer, pass back error=2
if (!dataxfer_ok) dispatchEvent({target:this, type:'mailSent', errorFlag:2});
// otherwise pass back error code returned from script
else dispatchEvent({target:this, type:'mailSent', errorFlag:Number(_lv["faultCode"])});
}
// Use loadvars object to send data (set to call dataReceived when script returns data)
public function sendEmail(sub:String, fn:String, fe:String, msg:String, rep:String):Void {
// if user already sent from this address, show error msg
if (_sentFrom == fe) dataReceived(false);
// otherwise set up and send
else {
_sentFrom = fe;
// specify function to handle results, make scope = Emailer
_lv.onLoad = Delegate.create(this, dataReceived);
// set up properties of lv to items to be POSTed
_lv.subject = sub;
_lv.name = fn;
_lv.email = fe;
_lv.message = msg;
_lv.reply = rep;
// call script
_lv.sendAndLoad("sendemail.php", _lv, "POST");
}
}
}
?>


6 Eylül 2007 Perşembe

Asp Report Maker



  • Detail and Summary Report
  • Crosstab Report
  • Simple Charts
  • Advanced Security
  • Export to HTML/Excel/Word
  • Custom View
  • Customizable Template
  • Database Synchronization

demo



Asp XmlMaker



  • Field as Element/Attribute
  • Filtering and Sorting
  • Master/Detail Data
  • Field Value Formatting
  • Null Value Handling
  • Custom View
  • Customizable Template
  • Template Extensions
  • Database Synchronization

demo


Jsp Maker




  • Create JSP for all tables
  • Form validation
  • User authentication
  • Database re-synchronization
  • Quick Generate Wizard
  • Customizable template
  • Master/Detail
  • File upload to folder or database
  • CSS stylesheet
  • Field Aggregation

demo



Php maker

* Advanced Security
* User registration system
* Export to CSV/HTML/Excel/Word/XML
* File uploading to database or folder
* Master/Detail
* Custom View
* Report
* Customizable template
* Database re-synchronization

Demo


Asp.net Maker



* All ASP.NET 2.0 scripts linked up properly
* Optional list, add/copy, view, edit, delete and search pages for each table/view. (See Table Setup) Customizable table display order.
* Fully customizable View and Edit format for each field. (See Field Setup) Customizable field display order.
* Various ASP.NET validators
* Optional search features (Basic/Advanced/Both) for each table/view
* Optional Advanced Security to protect data from unauthorized access (See Security Settings)
Complete user registration system
* Optional HTML settings. Charset, font, CSS, HTML colors, HTML table settings with preview. (See HTML Settings)
* Fully customizable template
* Master/Detail pages
* Various ASP.NET options (See ASP.NET Settings)
* Saving and restoring project from Project File
* Synchronizes project settings with changes in database.
* Creates virtual directory in IIS automatically
* Cassini or IIS as testing web server
* CSS stylesheet integration
* Field aggregation (sum, average and count)
* Custom View with built-in visual query builder
* Basic reporting
* ASP.NET inline editing
* Export to HTML/Word/Excel/CSV/XML
* Multi-column Sorting
* User Selectable Page Size
* Table-specific List Page Options
* File Uploading to Folder and Database
* Dynamic Table Loading
* Composite key
* Inline Delete
* Highlight and select row color
* Auto suggest textbox (ASP.NET AJAX)
* Adding option to Selection List (ASP.NET AJAX)
* Dynamic Selection List (ASP.NET AJAX)
* Dynamic User Levels
* Parent User ID
* Auto-login
* Extended quick search
* Multi-page update
* Fully customizable template and extensions
* Audit trail and email notification on Add/Edit/Delete

demo


5 Eylül 2007 Çarşamba

Aptana ide



Aptana is a robust, JavaScript-focused IDE for building dynamic web applications.Highlights


include the following features:
* Code Assist on JavaScript, HTML, and CSS languages, including your own JavaScript functions *Outliner that gives a snapshot view of your JavaScript, HTML, and CSS code structure
* FTP/SFTP uploading, downloading and synchronization
* JavaScript debugger to troubleshoot your code
* Error and warning notification for your code
* Support for Aptana UI customization and extensions
* Cross-platform support
* Free and source open under the Aptana Public License, v1.0.
* Please note that milestone 9 is still a preview release