Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/2013/Archives for August 2013

Archives for August 2013

August 30, 2013

Open With Application Duplicate

If you’re a Mac user, you can open up a file by right-clicking on it, and choosing “Open With,” and selecting an application. If you see duplicates, you can remove multiple entries by running the following script. The script restarts the Launch Register called lsregister and removes the duplicates.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Right click the file again. The duplicates should be gone.

Filed Under: Mac Tagged With: mac os

August 22, 2013

PHPMailer and GMail SMTP

Although PHP comes with its own email() function, it lack features. There’s an alternative called PHPMailer that’s easy to implement. PHPMailer is a library class used by many popular PHP projects. In this article, I’ll show how PHPMailer is used to send out notification emails via GMail’s STMP server. Using GMail SMTP server requires an account as well as the need to authenticate. So, here’s the code using PHPMailer and GMail SMTP server.

// email class
require_once('class.phpmailer.php');
 
$mail             = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "domain.tld";          // SMTP server
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
$mail->Username   = "name@gmail.com";      // GMAIL username
$mail->Password   = "password";            // GMAIL password
$mail->Subject    = "Your Subject";
$mail->Body       = "Your message.";
 
// recipient      
$address          = "name@domain.tld";
$mail->AddAddress($address, "Your Friend");
 
// sender
$mail->SetFrom('name@gmail.com', 'Your Name');
$mail->AddReplyTo("name@gmail.com","Your Name");
 
// send out email
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

// email class require_once('class.phpmailer.php'); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "domain.tld"; // SMTP server $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "tls"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 587; // set the SMTP port for the GMAIL server $mail->Username = "name@gmail.com"; // GMAIL username $mail->Password = "password"; // GMAIL password $mail->Subject = "Your Subject"; $mail->Body = "Your message."; // recipient $address = "name@domain.tld"; $mail->AddAddress($address, "Your Friend"); // sender $mail->SetFrom('name@gmail.com', 'Your Name'); $mail->AddReplyTo("name@gmail.com","Your Name"); // send out email if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; }

Include the code in your projects. You can also create a function and call the function each time you need to send out an email notification. Off course, you’ll need to pass variables such as recipients, body message, etc to complete your function.

Filed Under: PHP Tagged With: gmail, phpmailer

August 9, 2013

Install Samba Shared Drive

What’s not to like with Samba. If you’re not familiar with Samba, it’s an open-source file and printer services which allows disparate clients to share files via SMB/CIFS standard, meaning there’s interoperability between Linux/Unix servers and Windows-based clients. This article will show you how to install a Samba shared drive on an Ubuntu Server.

Install Samba Server

sudo apt-get install samba

sudo apt-get install samba

Configure Samba by editing /usr/samba/smb.conf. Uncomment and add the following.

security = user
 
[share]
comment = Ubuntu File Server Share
path = /home/ulysses/share
browsable = yes
guest ok = yes
read only = no
create mask = 0755

security = user [share] comment = Ubuntu File Server Share path = /home/ulysses/share browsable = yes guest ok = yes read only = no create mask = 0755

Create the shared drive.

sudo mkdir /home/ulysses/share
sudo chown nobody.nogroup /home/ulysses/share
sudo chmod -R 0777 /home/ulysses/share

sudo mkdir /home/ulysses/share sudo chown nobody.nogroup /home/ulysses/share sudo chmod -R 0777 /home/ulysses/share

Restart Samba Server

sudo restart smbd
sudo restart nmbd

sudo restart smbd sudo restart nmbd

Test the shared drive by accessing it from another computer or from another OS like a Mac or Windows.

Filed Under: Linux Tagged With: samba

  • 1
  • 2
  • Next Page »
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021