Note: setting javaMail on Raspberry Pi

Details

I wanted to receive mail with Raspberry Pi, so I decided to use javaMail. Since javaEE is not included in Raspberry Pi by default, I decided to include javaMail alone.

This time, I will make a note of this because I focused on the classPath that I had not been familiar with until now.

Download javaMail

It seems that javaMail and JAF are used to use javaMail, so download both from the following URL. -JavaMailJAF

Setting

If you unzip the two downloaded files, the following directory will appear. スクリーンショット 2019-03-21 0.11.18.png

To use javaMail, set two jar files, mail.jaf and activation.jar, in your CLASSPATH.

There are two main ways to set the UNIX CLASSPATH, and the method differs depending on the shell. Reference: Classpath

//shell(csh)in the case of
setenv CLASSPATH classpath 1: classpath 2

//shell(bash)in the case of
CLASSPATH=Classpath 1: Classpath 2; export CLASSPATH

**Checking the shell**
echo $SHELL

You can find out what the shell of your OS is by clicking "Check Shell". Raspberry is bash. スクリーンショット 2019-03-21 0.34.52.png In my case it looks like this. Also, separated by: (colon). (Dot) represents the current directory.

This completes the CLASSPATH setting.

Verification

Compile the following silly program to make sure the CLASSPATH is set.

Sample.java


import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class Sample{
 public static void main(String args[]){
  System.out.println("OK");
 }
}

I think it's okay if you can compile with this without any problems.

Impressions

Until now, I wasn't sure about CLASSPATH, but now I can use it with this "this". The details remain ambiguous, but let's do this this time! !!

It took a long time to set up, and I was tired and the notes became cluttered. From the next time, I want to finish the work more efficiently.

I don't know anything about this field, so if you make a mistake, please point it out in the comments. Also, please comment if you would like to share some tips.

Recommended Posts

Note: setting javaMail on Raspberry Pi
Install Docker on Raspberry Pi
Put Ubuntu 20.04.1 on Raspberry Pi 4
Minecraft server on Raspberry Pi 4
Install MariaDB on Raspberry Pi OS
Try putting CentOS 8 on Raspberry Pi 3
Headless install of Ubuntu 20.10 on Raspberry Pi
I installed Docker on my Raspberry Pi 3
Install CentOS 7 on Raspberry pi 4 Model B
Launched Redmine with Docker on Raspberry Pi 3
Serially connect to Ubuntu on Raspberry Pi
Install Ubuntu Core 18 on Raspberry Pi 2 Model B
Install Docker on Raspberry Pi 4 and Raspberry Pi OS 64bit
Radiko recording server on Raspberry Pi 4 (Docker unused)
Send emails using Docker container on Raspberry Pi 3
Build Ubuntu 20.04 LTS desktop environment on Raspberry Pi 4 (+ Japanese)
How to run javafx with Raspberry Pi Posted on 2020/07/12
Display characters on I2C 1602 LCD with Raspberry Pi 3 & Java
Setting JAVA_HOME on Ubuntu
[Note] Basic information setting (gradle)
Note: Install PostgreSQL 9.5 on Ubuntu 18.04
Install Cloud9 on Raspberry pi 4 and set up Rails development environment
Install Docker and docker-compose on Raspberry Pi 4, Linux (Debian) and Windows 10, respectively
20.10 is better than 20.04 for USB booting Ubuntu on Raspberry Pi 4B
Create Dockerfile, docker-compose.yml and run nodejs on windows10, Linux, Raspberry Pi
Display user-defined characters on the I2C 1602 LCD with Raspberry Pi 3 & Java