Public Const RAS_MAXENTRYNAME As Integer = 256 Public Const RAS_MAXDEVICETYPE As Integer = 16 Public Const RAS_MAXDEVICENAME As Integer = 128 Public Const RAS_RASCONNSIZE As Integer = 412
Public Type RasEntryName dwSize As Long szEntryName(RAS_MAXENTRYNAME) As Byte End Type
Public Type RasConn dwSize As Long hRasConn As Long szEntryName(RAS_MAXENTRYNAME) As Byte szDeviceType(RAS_MAXDEVICETYPE) As Byte szDeviceName(RAS_MAXDEVICENAME) As Byte End Type
Public Declare Function RasEnumConnections Lib _ "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As _ Any, lpcb As Long, lpcConnections As Long) As Long
Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _ "RasHangUpA" (ByVal hRasConn As Long) As Long
Public gstrISPName As String Public ReturnCode As Long
Public Sub HangUp() Dim i As Long Dim lpRasConn(255) As RasConn Dim lpcb As Long Dim lpcConnections As Long Dim hRasConn As Long lpRasConn(0).dwSize = RAS_RASCONNSIZE lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize lpcConnections = 0 ReturnCode = RasEnumConnections(lpRasConn(0), lpcb, _ lpcConnections)
If ReturnCode = ERROR_SUCCESS Then For i = 0 To lpcConnections - 1 If Trim(ByteToString(lpRasConn(i).szEntryName)) _ = Trim(gstrISPName) Then hRasConn = lpRasConn(i).hRasConn ReturnCode = RasHangUp(ByVal hRasConn) End If Next i End If
End Sub
Public Function ByteToString(bytString() As Byte) As String Dim i As Integer ByteToString = "" i = 0 While bytString(i) = 0& ByteToString = ByteToString & Chr(bytString(i)) i = i + 1 Wend End Function
' Check that there is at least one '@' bTemp = InStr(sEMail, "@") <= 0 If bTemp Then GoTo exit_function
' Check that there is at least one '.' bTemp = InStr(sEMail, ".") <= 0 If bTemp Then GoTo exit_function
' and that the length is at least six (a@a.ca) bTemp = Len(sEMail) < 6 If bTemp Then GoTo exit_function
' Check that there is only one '@' i = InStr(sEMail, "@") sTemp = Mid(sEMail, i + 1) bTemp = InStr(sTemp, "@") > 0
If bTemp Then GoTo exit_function 'extra checks ' AFTER '@' space is not allowed bTemp = InStr(sTemp, " ") > 0 If bTemp Then GoTo exit_function
' Check that there is one dot AFTER '@' bTemp = InStr(sTemp, ".") = 0 If bTemp Then GoTo exit_function
' Check if there's a quote (") bTemp = InStr(sEMail, Chr(34)) > 0 If bTemp Then GoTo exit_function
' Check if there's any other disallowed chars ' optimize a little if sEmail longer than sInvalidChars ' check the other way around If Len(sEMail) > Len(sInvalidChars) Then For i = 1 To Len(sInvalidChars) If InStr(sEMail, Mid(sInvalidChars, i, 1)) > 0 _ Then bTemp = True If bTemp Then Exit For Next Else For i = 1 To Len(sEMail) If InStr(sInvalidChars, Mid(sEMail, i, 1)) > 0 _ Then bTemp = True If bTemp Then Exit For Next End If If bTemp Then GoTo exit_function
' extra check ' no two consecutive dots bTemp = InStr(sEMail, "..") > 0 If bTemp Then GoTo exit_function
exit_function: ' if any of the above are true, invalid e-mail IsValidEmail = Not bTemp
What is PHP? PHP, which stands for "Hypertext Preprocessor", is a server-side, HTML embedded scripting language used to create dynamic Web pages. Much of its syntax is borrowed from C, Java and Perl with some unique features thrown in. The goal of the language is to allow Web developers to write dynamically generated pages quickly.
In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the page, the server processes the PHP code and then sends the output (not the PHP code itself) to the visitor's browser. It means that, unlike JavaScript, you don't have to worry that someone can steal your PHP script.
PHP offers excellent connectivity to many databases including MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, and Generic ODBC. The popular PHP-MySQL combination (both are open-source products) is available on almost every UNIX host. Being web-oriented, PHP also contains all the functions to do things on the Internet - connecting to remote servers, checking email via POP3 or IMAP, url encoding, setting cookies, redirecting, etc.
Basic Syntax
* File name: You should save your file with the extension .php (earlier versions used the extensions .php3 and .phtml). * Comments: // This comment extends to the end of the line. /* This is a multi-line comment */ * Escaping from HTML: A PHP code block starts with <?php" and ends with "?>. A PHP code block can be placed anywhere in the HTML document. * Instruction separation: Each separate instruction must end with a semicolon. The PHP closing tag (?>) also implies the end of the instruction.
This tip provides information on use of utility Command line email client in PHP script. Use of standard PHP mail() function which allows you to send mail, is very complicated. By using febooti Command line email you can:
Send email message using plain text or HTML message with embedded pictures.
Send unlimited number of attachments.
Use return codes to check success or failure.
Works on Microsoft Windows (98 / Me / NT / 2000 / 2003 / XP / Vista) including all server versions.
And many more options...
Sample PHP script:
/**** febootimail PHP email ****/ <?php // Send e-mail from PHP and output the result. // (On a MS Window operating system with // the "febootimail.exe" executable in the path).
$server=' -SMTP smtp.sender.com -PORT 25';
$body='"This is <I>HTML / MIME</I> e-mail message"'; $body.='" sent with <B>febooti Command line email</B>"';