Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:587 (Connection timed out)

Re: unable to connect to ssl://smtp.gmail.com:587 (Connection timed out)

This is the error you get if your server firewall is blocking port 587. This error message is usally given by a CMS or other PHP scripts that is unable to send messages to the Google SMTP server.

To resolve simply allow incoming and outgoing traffic through port 587 and restart your server firewall.

How to disable Plesk open_basedir restriction in effect

Some applications require open_basedir to be “loosened” a little, if you are installing an application such as ClickCart Pro then the open_basedir will need to be changed so that the installation can create the required sub directories and then complete.

Let’s assume your domain name is domain.com (no such luck, I know!)

# vi /var/www/vhosts/domain.com/vhost.conf

Add the following lines:

<Directory /var/www/vhosts/domain.com/httpdocs>
php_admin_value open_basedir “/var/www/vhosts/domain.com”
php_admin_flag safe_mode off
</Directory>

Now we need to rebuild the apache configuration:

# /usr/local/psa/admin/sbin/websrvmng -u –vhost-name=domain.com

Job done, your open_basdir setting has been moved up one level (from /httpdocs to /) within your domain name sub folder.

How to set the default PHP.INI timezone

Messages in error_log: Please use the date.timezone setting, PHP Strict Standards:  strtotime() [<a href=’function.strtotime’>function.strtotime</a>]: It is not safe to rely on the system’s timezone settings. Please use the date.timezone setting

The default timezone setting in your PHP.INI is not set.

Edit you PHP.INI using your favourite editor eg.

# vi /etc/php.ini

Change this:

[Date]
; Defines the default timezone used by the date functions
; date.timezone =

To this:

[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/London"

This will resolve the problem.

How is PHP setup in your servers?

We have phpSuExec configured in our servers. As such, PHP is setup as FastCGI instead of an Apache module. This offers users security to the way PHP is used in a shared hosting environment.

Categories PHP

How do I change the PHP Mail() from address?

When using the PHP Mail() function you will find that the ‘from’ email address is often an unfriendly looking system email address sometimes even belonging to the root or system user, this can confuse your userbase as well as making it impossible for them to reply to any system messages that you send.

To make this change you first need to decide which email address you would like the from address to represent. This email address must exist on the server where your PHP Mail() function is being called, if the email address you choose does not exist, then your efforts will be wasted.

$result = mail(“to@address.com”, “subject”, “message”, “From: other@address.com\n”, “-fother@address.com”);

Make sure that the other@address.com exists on the server, if it does not, this will not work.

If you have any problems simply contact the Helpdesk for further assistance,

Categories PHP