Annunci
RSS

Archivio mensile:marzo 2013

Using SSMTP Mail Client With PHP

After installing the SSMTP (Linux Mail Client)

http://peterwadid.com/2013/03/26/linux-ssmtp-mail-client-configuration/

Now We are going to use it with PHP, Just Create a file (mailTest.php)

mailTestPhp

Then ,

MailSend

 

Finally , Test your PHP Script from the Command Line

CallPHPScript

Annunci
 
Lascia un commento

Pubblicato da su marzo 27, 2013 in Linux

 

Linux SSMTP Mail Client Configuration


ssmtpConf

Add these lines to the ssmtp configuration file (ssmtp.conf)

ssmtpConf2

 

 

 
2 commenti

Pubblicato da su marzo 26, 2013 in Uncategorized

 

Share your Programming Experience

An Invitation to all our followers.
Here you can share your programming experience with us.
So that we can help others to find solutions for their programming problems
you can post in whatever programming language you want.

Thanks
Peter Eskandar

TeamWork

 
2 commenti

Pubblicato da su marzo 26, 2013 in Programming

 

Send Mail using PHP , EasyPHP and Gmail

To run this example you have to :

  • Install EasyPHP
  • Download PHPMailer https://github.com/Synchro/PHPMailer
  • Put the PHPMailer folder inside the PHP installation folder, in my case C:\Program Files\EasyPHP12.1\php\
  • Modify Some parameters in PHP Configuration file (php.ini) 
    • insert this line include_path = “.;${path}\php\phpmailer”
    • set smtp_port = 465
    • SMTP = smtp.gmail.com
    • and uncomment this line extension=php_openssl.dll

After tha Create email.php and put it in your WWW root folder

<?php
require(“phpmailer/class.phpmailer.php”);
$mail = new PHPMailer();
$mail->IsSMTP();

//GMAIL config
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = “ssl”; // sets the prefix to the server
$mail->Host = “smtp.gmail.com”; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = “put ur gmail account here”; // GMAIL username
$mail->Password = “ur email password”; // GMAIL password
//End Gmail

$mail->From = “ur gmail account again”;
$mail->FromName = “name”;
$mail->Subject = “some subject”;
$mail->MsgHTML(“the message”);

//$mail->AddReplyTo(“reply@email.com”,”reply name”);//they answer here, optional
$mail->AddAddress(“destination email address”,”name to”);
$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {//to see if we return a message or a value bolean
echo “Mailer Error: ” . $mail->ErrorInfo;
} else echo “<script>alert(‘Email sent’)</script>”;
// echo “Message sent!”
?>

 Test the page using the following URL : http://localhost:8080/email.php
if you get this message, then you have successfully sent your email

 

 

PHPMail

 

 
Lascia un commento

Pubblicato da su marzo 26, 2013 in Programming

 

Tag: ,

Execute CMD Commands Using a Simple Java Interface

CMDSimulator

 

package cmd;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

 

public class JavaRunCommand extends JFrame {

   private JTextField CMDField = new JTextField(40);
   private JButton ExecuteButton = new JButton(“Execute Command”);
   private JLabel CommandLabel = new JLabel(“Command: “);
   private JTextArea OutPut = new JTextArea(20, 30);
   private JScrollPane jsp = new JScrollPane(OutPut);

   public JavaRunCommand( ) {
   super(“CMD Simulator”);
   Container contentPane = this.getContentPane( );
   contentPane.setLayout(new BorderLayout( ));
   JPanel labels = new JPanel( );
   labels.setLayout(new GridLayout(4, 1));
   labels.add(CommandLabel);

  JPanel fields = new JPanel( );
  fields.setLayout(new GridLayout(4, 1));
  fields.add(CMDField);

  Box north = Box.createHorizontalBox( );
  north.add(labels);
  north.add(fields);
  contentPane.add(north, BorderLayout.NORTH);
  OutPut.setFont(new Font(“Monospaced”, Font.PLAIN, 12));
  contentPane.add(jsp, BorderLayout.CENTER);

  JPanel south = new JPanel( );
  south.setLayout(new FlowLayout(FlowLayout.CENTER));
  south.add(ExecuteButton);
  ExecuteButton.addActionListener(new ActionButton( ));
  contentPane.add(south, BorderLayout.SOUTH);
  this.pack();
}

  class ActionButton implements ActionListener
{

@Override
  public void actionPerformed(ActionEvent arg0) {
  // TODO Auto-generated method stub
  String CMD = CMDField.getText() ;
  try {
  // Run “netsh” Windows command
  Process process = Runtime.getRuntime().exec(CMD);
  String temp = “”;

// Get input streams
  BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
  BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));

// Read command standard output
  String s;
  System.out.println(“Standard output: “);
  while ((s = stdInput.readLine()) != null) {
  System.out.println(s);
  temp +=s + “\n”;
}
 OutPut.setText(temp);

// Read command errors
  System.out.println(“Standard error: “);
  while ((s = stdError.readLine()) != null) {
  System.out.println(s);
  OutPut.setText(s);
  temp +=s + “\n”;
}
  OutPut.append(temp);
} catch (Exception e) {
e.printStackTrace(System.err);
}

}

}

public static void main(String[] args) {
JavaRunCommand client = new JavaRunCommand();
// Next line requires Java 1.3 or later. I want to set up the
// exit behavior here rather than in the constructor since
// other programs that use this class may not want to exit
// the application when the SMTPClient window closes.
client.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
client.show( );
}
}

 
Lascia un commento

Pubblicato da su marzo 25, 2013 in Programming