Monday, May 24, 2010

PHP localhost mail function

To make Ubuntu PHP localhost mail function work, using PHP to send mail from localhost is easy. First, you need to install some PEAR mail packages.

In terminal, run the following command one by one:
sudo pear install mail
sudo pear install Net_SMTP
sudo pear Auth_SASL
sudo pear install mail_mime

After installing the pear packages, you need to install and configure postfix, first, run the following command to install postfix:

sudo apt-get install postfix

after installation, a configuration window will be displayed, you need to configure it:

Step 1: Choose Internet Site

Step 2: Enter localhost at the input area

For the rest of the steps, just follow the default settings. After complete the configuration, it’s time to test the PHP script. Create a PHP file called sendmail.php at your localhost, and copy and paste the code below into it (remember to change the email addresses to yours)

include('Mail.php');
include('Mail/mime.php');
// Constructing the email
$sender = "shi ";
$recipient = "Leigh ";
$subject = "Test Email";
$text = 'This is a text message.';
$html = '

This is a html message

';
$crlf = "\n";
$headers = array(
'From' => $sender,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
// Set body and headers ready for base mail class
$body = $mime->get();
$headers = $mime->headers($headers);
// SMTP params
$smtp_params["host"] = "localhost"; // SMTP host
$smtp_params["port"] = "25"; // SMTP Port (usually 25)
// Sending the email using smtp
$mail =& Mail::factory("smtp", $smtp_params);
$result = $mail->send($recipient, $headers, $body);
if($result == 1)
{
echo("Your message has been sent!");
}
else
{
echo("Your message was not sent: " . $result);
}
?>

Thursday, May 20, 2010

Ioncube

ionCube Loader

In today's world, copyright is a very important issue, especially when talking about websites. By default, when creating a website, your code is publicly available for everyone - all they have to do is use the “View Source” option to check the code with their web browser, or download your files and review the product of your hard work for free. To prevent this, a lot of companies have created special tools, which can obfuscate your code and make it impossible for anyone but you to view it, not affecting your website work at all. They are called Encoders, and one of the most popular combinations is the ionCube Loader and Encoder.

ionCube Loader is a software tool, with the help of which you can run files encoded with the ionCube PHP Encoder. It protects the PHP 4 and PHP 5 source code, as well as other files in your website, and prevents them from stealth and unauthorized modification. What is even more, the encoded files run smoothly, showing excellent performance on any web server having ionCube support.

ionCube Encoder

When using encrypted web pages, there are always two tools that you need to use. The first one is the decoder, which is server based and will decode the encrypted web pages, allowing the user to actually see them online. The second one is the actual Encoder, which is software you need to have on your machine in order to encode your files. The ionCube Encoder will do that for you, protecting your files from unauthorized changes and modifications.

How to check if ionCube is installed on the server ?

There is an easy way to check if the ionCube Loader is already present on your web server - by using a phpinfo.php file. This is a simple file, which makes usage of the "phpinfo()" function. When accessed online, this function will show you complete information about the PHP settings on the server, alongside with the installed modules.