- Published:
- September 5, 2007 @ 12:38 am
- Category:
- Server Administration, PHP
- Author:
- Chris Wheeler
I’ve recently come across a problem where automated emails are getting blocked by a number of ISPs. I’ve tracked this down to the sender verification methods some ISPs use - If an email comes from an address which isn’t an active mailbox on the server, it is sometimes dropped without any notice to the sender or recipient.
A fair few web sites send automated emails from addresses such as no-reply@domain.com do-not-reply@domain.com forum@domain.com etc - if these accounts are not setup the mails will be discarded by some servers.
You should always use a real email account to send emails - even if it silently discards all incoming mail.
Another problem is that if PHP’s mail() function is being used, and php is running as the userĀ ’nobody’, emails by default will be sent from nobody@hostname.isp.com - which in most cases does not exist.
The way around this is to specify the senders email address through the mail function. e.g.
mail($to, $subject, $body, $headers, '-f sales@domain.com')
Note: Even if you have set the ‘From: ‘ field in the email headers, the email envelope address may still be set to a different account, using the ‘-f email@address’ parameter will fix this, and your emails should reach your customers!
- Published:
- May 17, 2007 @ 12:56 pm
- Category:
- Server Administration
- Author:
- Chris Wheeler
While its possible to use Smarty by simply uploading it to your user account and then including it in your project, its much cleaner to install it onto your server, and then simply include it in your scripts with
require_once('Smarty.class.php');
Installing Smarty is a simple process, all you have to do is download it, extract it to your servers php libs directory, then make sure its inlcuded in you php_include path. Once you have done this, you will only need to keep one version up to date, as well as saving disk space if you have multiple sites powered by Smarty.
Step 1: Download & Extract Smarty
Smarty 2.6.18 is the latest version at the time of writing, however please check the official Smarty website for the latest version, and ammend the commands below if applicable.
$ cd /usr/local/lib/php/
$ wget "http://smarty.php.net/do_download.php?download_file=Smarty-2.6.18.tar.gz"
$ gtar -zxvf Smarty-2.6.18.tar.gz
$ mkdir Smarty
$ cp -r Smarty-2.6.18/libs/* Smarty
$ rm Smarty-2.6.18.tar.gz
Step 2: Add to php’s include path
Open up your php.ini and edit the include path to include “/usr/local/lib/php/Smarty”. The location of your php.ini file can be found by creating a script with a call to phpinfio() in it, you cal also use this to verify the changes to the include_path once you have made them. Mine include_path looks like the example below.
; UNIX: "/path1:/path2"
include_path = ".:/php/includes:/usr/local/lib/php/Smarty"
While this guide is intended to be generic, your server settings and directory structure may vary, so please be careful!