PHP test to check whether a port is open or not

You need to replace the
$address =”the_test_address.com”;
$port = ‘port_number’;

/*Code starts*/
/*port test*/

<?php
$address=”smtp.gmail.com”;
$port = ‘456’;
if (isset($port) and
($socket=socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and
(socket_connect($socket, $address, $port)))  {
$text=”Connection successful on IP $address, port $port”;
socket_close($socket);
}
else  {
$text=”Unable  connect<pre>”.socket_strerror(socket_last_error()).”</pre>”;
}
echo “<html><head></head><body>”.
$text.
“</body></html>”;
?>

/*code ends*/
code courtesy: http://php.net/socket_connect

How to test :- Copy this code to a file say, porttest.php, change the $address , $port to the required and put it somewhere accessible by your server , like /var/www/ in linux. And run the same by opening localhost/porttest.php

Advertisements

Setting up SMTP mail server for locally hosted Mediawiki

Email service is a MediaWiki Component, which do not come pre-configured and requires some edits to the LocalSettings.php to set up. Basically, you are sending mails from your mediawiki running on your localhost/ or vagrant using the gmail smtp server.

  1. You need to install the following packages :
  2. sudo apt-get install php-pear
    sudo pear install mail
    sudo pear upgrade MAIL Net_SMTP

  3. Now edit your LocalSettings.php to include :

    $wgEmergencyContact = “apache@localhost”;
    $wgPasswordSender = “apache@localhost”;
    $wgNoReplyAddress = “user@gmail.com”;

    $wgSMTP = array(
    ‘host’ => “ssl://smtp.gmail.com”,
    ‘IDhost’ => “gmail.com”,
    ‘port’ => 465,
    ‘auth’ => true,
    ‘username’ => “user@gmail.com”,
    ‘password’ => “yourPassword”
    );

If your firewall doesn’t check port 465 && smtp service is unblocked, you are ready to send your mail.  In order to test, go to
localhost/mediawiki/Special:ConfirmEmail
and click on send Confirmation Code. Check your inbox ! 🙂
Instructions to check whether your port is open will be included in the next post.
Courtesy:https://help.ubuntu.com/community/MediaWiki#Email_Support