Brother DCP-J152W setup scanner

by GarciaPL on Sunday 14 September 2014

Printing some docs on Ubuntu using one of the printer delivered by Brother is quite easy. You just need to install appropriate packages (deb or rpm) and after that you can easily setup your Brother printer (in my case Brother DCP-J152W) connected via USB or WiFi due to future prints.

Linux user may deal with some problem when there is a need to use scanner built-in Brother device. Fortunately there is a solution of this problem. In this case Brother printer is connected to router byWiFi :

  1. Download and install those packages : brscan4brscan-skey and brother-udev-rule.
  2. Check if you Brother model is available to configure - run command in terminal - brsaneconfig4 -q
  3. If you Brother model is on the list after perform previous step, then you can configure it - brsaneconfig4 -a name=DCPJ152W model=DCP-J152W ip=192.168.1.102
  4. Test if your Brother printer is available through the network - brsaneconfig4 -p. If your device is responding, you can go to the next step.
  5. Finally use tools like XSane or VueScan to scan your docs using Brother scanner.

Reference : [1] Support.brother.com - DCP-J152W Downloads [2] Support.brother.com - Scanner driver install for network [3] Unix.stackexchange.com - Brother DCP-J315W is active in terminal but not detected in Elementary OS [4] Secure.kitserve.org.uk - Ubuntu Brother Printer-Scanner Network Setup

Send email using Gmail account

by GarciaPL on Wednesday 10 September 2014

I would like to share with you a small snippet which will allow you to send email using Gmail account. In this case I will use JavaMail (javax.mail) interface for sending email messages. More information about JavaMail API reference you can find below.

import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

private void sendEmail() {

        String sender = "sender@gmail.com";
        String receiver = "receiver@gmail.com";
        String title = "YOUR_TITLE_TEXT";
        String body = "YOUR_BODY_TEXT";

        Properties props = new Properties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "25");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.EnableSSL.enable", "true");
        props.put("mail.smtp.auth", "true");
        props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        props.setProperty("mail.smtp.socketFactory.fallback", "false");
        props.setProperty("mail.smtp.port", "465");
        props.setProperty("mail.smtp.socketFactory.port", "465");

        Authenticator authenticator = new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("login@gmail.com", "password");
            }
        };

        Session session = Session.getDefaultInstance(props, authenticator);

        try {
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(sender));
            msg.addRecipient(Message.RecipientType.TO,
                    new InternetAddress(receiver, receiver));
            msg.setSubject(title);
            msg.setText(body);
            Transport.send(msg);
        } catch (MessagingException e) {
            System.out.println("sendEmail (MessagingException) : " + e.getMessage());
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            System.out.println("sendEmail (UnsupportedEncodingException) : " + e.getMessage());
            e.printStackTrace();
        } catch (Exception e) {
            System.out.println("sendEmail (Exception) : " + e.getMessage());
            e.printStackTrace();
        }
}
If you are using Gmail account to send emails, properties related with smtp configuration in this snippet will remain, but you should change variables like sender, receiver, title and body to your needs. You should also change login and password in below line which will be used to authenticate with gmail account :


return new PasswordAuthentication("login@gmail.com", "password");
Reference : [1] Oracle®'s JavaMail API reference [2] Pastebin Source