Author Archives: xMoDx

How to Send email direct from linux terminal

To send an email from console you need to use mail command, which is an intelligent mail processing system which has a command syntax reminiscent of ed with lines replaced by messages.

To send an email to [email protected] you need to type following command:

$ mail [email protected]
Output:

Subject: Hello
Hi,
Kamusta kana? sana ok ka/// :)
Ingats
xMoDx
. <Type  DOT (.) followed by ENTER KEY>
Cc: <Press ENTER KEY>

You need to type . (dot) to send an email.

To send contains of file (such as /var/log/messages) as mail body then use following command:

$ mail -s 'Subject here' [email protected] < /var/log/messages

Please note that above command will NOT route an email if you do not have properly configured MTA/mail server. and check your spam folder for paid services like gmail for the mail might end up there

Test if local SMTP server is running

To test if a local SMTP server is running, you can try to ping the port 25

$ echo -e “quit” | nc localhost 25

220 ubuntu ESMTP Postfix (Ubuntu)
221 2.0.0 Bye
If no SMTP server is listening

$ echo -e “quit” | nc localhost 25

localhost.localdomain [127.0.0.1] 25 (?) : Connection refused

Ways to Add JavaScript to WordPress Posts or Pages

You might have modified your WordPress theme to add a JavaScript code but there are times when you may want to add JavaScript to a specific post or page. So, In this post I will explain you how to add JavaScript code to single WordPress post or page.

  • If you are running a self hosted WordPress blog than you can simple add the JavaScript code to your post through the built-in editor, just switch to HTML mode and paste the code.

Adding JavaScript in WordPress Posts and Pages

  • Alternatively, you can install a WordPress Plugin “Allow Javascript in Posts and Pages” which enables you to add JavaScript to blog posts and pages just by adding a simple short-code.
  • And if you don’t want to install an extra plugin to your WordPress Blog you can simply add a Custom Field (js)and paste the JavaScript code into the Value field. After that just add short-code in your post –
    js

    .

Adding JavaScript in WordPress using Custom Fields

Adding JavaScript in WordPress posts using Custom Fields

 

bubbleindia[dot]com thanks for this guide im using this for personal reference

How do I test PHP SMTP functionality?

You can test PHP SMTP functions with the following two examples. The first one is standard SMTP while the second one is SMTP with SSL.

Sending with PHP SMTP

You will only need to change the following variables:

  • $from
  • $to
  • $subject
  • $body
  • $username
  • $password
<?php
require_once "Mail.php";

$from = "Web Master <[email protected]>";
$to = "Nobody <[email protected]>";
$subject = "Test email using PHP SMTP\r\n\r\n";
$body = "This is a test email message";

$host = "mail.emailsrvr.com";
$username = "[email protected]domain.tld";
$password = "yourPassword";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>

Sending with PHP SMTP with SSL

You will only need to change the following variables:

  • $from
  • $to
  • $subject
  • $body
  • $username
  • $password
<?php
require_once "Mail.php";

$from = "Web Master <[email protected]>";
$to = "Nobody <[email protected]>";
$subject = "Test email using PHP SMTP with SSL\r\n\r\n";
$body = "This is a test email message";

$host = "ssl://secure.emailsrvr.com";
$port = "465";
$username = "[email protected]";
$password = "yourPassword";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>

how to upgrade PHP 5.1 To 5.2 centos

This guide describes how to upgrade the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.2.x. These instructions were created using CentOS 5.3 32-bit and with the following PHP packages installed:

# rpm -qa |grep php

 php-common-5.1.6-15.el5.i386
 php-cli-5.1.6-15.el5.i386
 php-5.1.6-15.el5.i386
 php-pdo-5.1.6-15.el5.i386
 php-bcmath-5.1.6-15.el5.i386
 php-ldap-5.1.6-15.el5.i386
 php-devel-5.1.6-15.el5.i386
 php-gd-5.1.6-15.el5.i386
 php-xml-5.1.6-15.el5.i386
 php-mbstring-5.1.6-15.el5.i386
 php-mysql-5.1.6-15.el5.i386
 php-dba-5.1.6-15.el5.i386

As long as you’re using the standard PHP packages on your CentOS server you won’t need to do anything extra. If you’re using extra PHP packages that aren’t part of the standard CentOS repositories (like php-mcrypt) you’ll have to remove them or find updated versions of them.

Add the development repositories
Continue reading