Sunday, November 9, 2008

Using PHP scripts to send an email

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>"';

$subj='PHP mail';

$command='febootimail.exe -HTML -MIME -FROM web@sender.com ';
$command.='-TO john@sender.com '.$body.$server;
$command.='-SUBJ '.$subj.' -BODY '.$body.$server;

$result=0;

exec($command,$output,$result);
echo 'Output: ';
print_r($output);
echo '<BR>';
echo 'Result: '.$result;

// For detailed information about result codes, see:
// Utility Command line email client with MS-DOS batch files - returned errorlevels
?>

Reference : http://expertsadvice.in

2 Comentários:

v said...

Banyak betul blog anda. Gimana maintain nya?

aipdam said...

maksih atas kunjunganx, sebenarnya sih repot juga maintainnya, cuma blog buat saya selain untuk cari recehan, juga sebagai media penyimpanan artikel yang saya anggap bagus saat surfing, yang dikelompokkan menurut tema dari blog tersebut. Sedikit demi sedikit lama2 khan jadi bukit. he he he :D

Post a Comment

Latest Comments

About Me

My photo
Makassar, Sulawesi Selatan, Indonesia

Guest Book


ShoutMix chat widget

Script Sense ©Template Blogger Green by Dicas Blogger.

TOPO