2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ドアホン画像を保存閲覧する設定(その1)

Last updated at Posted at 2021-05-24

Panasonicドアホンには、ドアホン子機・センサーカメラ・ワイヤレスカメラからの画像をメール送信する機能があり、このメールをRaspberryPiで受信する場合の設定をメモする。
##背景
メールサーバの指定を smtp.gmail.com, smtp.mail.yahoo.co.jp, smtp.nifty.com など使って外部のメールに送信しても良いが、大量の画像メールの送信となると見通すことは困難だ。LAN内のローカルファイルに保存して、サムネール画像でブラウズ出来るようにした。

機材環境

・ドアホン親機 VL-MWH705(Panasonic)
・ドアホン子機 VL-VH556L x2
・センサーカメラ VL-CD265 x3
・ワイヤレスカメラ VL-WD813K
・RaspberryPi4 PiOSは /boot/issue.txt (2020-05-27) 版
  ssh user@192.168.0.8 でログインしてroot操作できる環境とする

○ 外観 画像 クリックで拡大

親機 ドアホン1 ドアホン2 Sカメラ1
Sカメラ2 Sカメラ3 Wカメラ1 RasPi4

exim4 dovecot bind9 メールサーバ設定

○ パッケージのインストール
 apt-get install exim4 (exim4-base exim4-config)
 apt-get install dovecot-imap4 (dovecot-core)
 apt-get install bind9 (bind9-host bind9utils)
###(1) /etc/exim4/update-exim4.conf.confの設定
egrep -v '^\s*#|^\s*$' /etc/exim4/update-exim4.conf.conf で内容を確認

dc_eximconfig_configtype='smarthost'
dc_other_hostnames='rapiq.localdom.jp'
dc_local_interfaces='127.0.0.1; 192.168.0.8; 192.168.1.28; ::1'
dc_readhost='rapiq.localdom.jp'  #メールを受け取るホスト名
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.nifty.com::587'  # gmail,yahoo でもOK
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'   # IMAP4向け

###(2) /etc/exim4/passwd.clientとpasswdの内容
外向きメール passwd.client smarthost先の認証ユーザ名とパスワード。
受信用メール passwd 受信認証用のユーザ名とパスワード。

# cd /etc/exim4
# cat passwd.client
#smtp.gmail.com:user@gmail.com:pass
smtp.nifty.com:user@nifty.com:pass

# /usr/share/doc/exim4/examples/exim-adduser
User: user
Password: mypass
# cat passwd
user:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:mypass

###(3) $HOMEにIMAP4用のディレクトリ作成

$ mkdir Maildir
$ chmod 700 Maildir

/usr/sbin/update-exim4.conf; /etc/init.d/exim4 restart で反映して再起動。

###(4) dovecotの設定

# cd /etc/dovecot
# diff dovecot.conf.org dovecot.conf
24c24,25
< !include_try /usr/share/dovecot/protocols.d/*.protocol
---
> #!include_try /usr/share/dovecot/protocols.d/*.protocol
> protocols = imap
56a58,59
> auth_verbose = yes
> auth_debug = yes

# diff conf.d.org/10-mail.conf conf.d/10-mail.conf
30c30
< mail_location = mbox:~/mail:INBOX=/var/mail/%u
---
> mail_location = maildir:~/Maildir

# /etc/init.d/dovecot restart
[ ok ] Restarting dovecot (via systemctl): dovecot.service.

###(5) bind9の設定

# cd /etc/bind
# diff -u named.conf.local.org named.conf.local
--- named.conf.local.org	2020-05-18 17:02:41.000000000 +0900
+++ named.conf.local	2021-05-15 20:11:11.537957026 +0900
@@ -6,3 +6,28 @@
 // organization
 //include "/etc/bind/zones.rfc1918";

+zone "localdom" {
+        type master;
+        file "/etc/bind/db.localdom";
+};
+
+zone "0.168.192.in-addr.arpa" {
+        type master;
+        file "/etc/bind/db.localdom.rev";
+};
+
+#logging {
+#       category lame-servers{ null; };
+#};
+    logging {
+        channel default-log {
+            file "/var/log/bind/named.log" versions 5 size 1m;
+            severity  debug;
+            print-time  yes;
+            print-category  yes;
+        };
+        category default {
+            default-log;
+        };
+    };
+// end of file.

# cat /etc/bind/db.localdom
;
; BIND data file for local loopback interface
;
$TTL	604800
@	IN	SOA	ns.localdom.jp. postmaster.localdom.jp. (
			  10001		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
	IN	NS	ns.localdom.jp.
;
localhost IN A	127.0.0.1
localdom.jp.	IN	MX	10	mx.localdom.jp.
ns	IN	A	192.168.0.8
mx	IN	A	192.168.0.8

obsa7   IN      A       192.168.0.6
rapiq   IN      A       192.168.0.8
        IN      MX      20      rapiq.localdom.jp.
rapip   IN      A       192.168.0.9
        IN      MX      30      rapip.localdom.jp.
vl705   IN      A       192.168.0.10

# cat /etc/bind/db.localdom.rev
;
; BIND reverse data file for local loopback interface
;
$TTL	604800
@	IN	SOA	localdom.jp. root.localdom.jp. (
			  10001		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
	IN      NS      ns.localdom.jp.
;
@	IN	A	255.255.255.0
;
6      IN      PTR     obsa7.localdom.jp.
8      IN      PTR     rapiq.localdom.jp.
9      IN      PTR     rapip.localdom.jp.
10     IN      PTR     vl705.localdom.jp.

# /etc/init.d/bind9 restart
[ ok ] Restarting bind9 (via systemctl): bind9.service.

# cat /etc/resolv.conf
domain localdom.jp
search localdom.jp
nameserver 192.168.0.8
nameserver 192.168.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
            #hostコマンドで mail is のMXレコード表示があること
# host rapiq
rapiq.localdom.jp has address 192.168.0.8
rapiq.localdom.jp mail is handled by 20 rapiq.localdom.jp.

###(6) ローカルエリア内のホストrapiq.localdom.jpで受信するかの確認

### telnetコマンドでテスト
user@rapip:~ $ telnet 192.168.0.8 25
Trying 192.168.0.8...
Connected to 192.168.0.8.
Escape character is '^]'.
220 rapiq ESMTP Exim 4.92 Mon, 17 May 2021 09:39:00 +0900
ehlo rapi
250-rapiq Hello rapip.localdom.jp [192.168.0.9]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH CRAM-MD5
250-CHUNKING
250-STARTTLS
250-PRDR
250 HELP
mail from: user@rapiq.localdom.jp
250 OK
rcpt to: user@rapiq.localdom.jp
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Subject: test
Hello world. Mon 17 May 09:39
.
250 OK id=1liRJ3-0006zh-18
quit
221 rapiq closing connection
Connection closed by foreign host.
user@rapip:~ $

### rapiq:/var/log/exim4/mainlog ### ログ確認
2021-05-17 09:40:33 1liRJ3-0006zh-18 <= user@rapiq.localdom.jp H=rapip.localdom.jp (rapi) [192.168.0.9] P=esmtp S=267
2021-05-17 09:40:38 1liRJ3-0006zh-18 => user <user@rapiq.localdom.jp> R=local_user T=maildir_home
2021-05-17 09:40:38 1liRJ3-0006zh-18 Completed

user@rapiq:~ $ ls -lt ~/Maildir/new|grep rapiq|head -1 ### 着信確認
-rw------- 1 user user  268 May 17 09:40 1621212038.26924_1.rapiq
### mailコマンドでテスト
$ echo "from rapiq `date`"|mail -s Test user@rapiq.localdom.jp

### rapiq:/var/log/exim4/mainlog ### ログ確認
2021-05-17 09:46:07 1liROZ-00070k-86 <= user@rapiq U=user P=local S=405
2021-05-17 09:46:07 1liROZ-00070k-86 => user <user@rapiq.localdom.jp> R=local_user T=maildir_home
2021-05-17 09:46:07 1liROZ-00070k-86 Completed

user@rapiq:~ $ ls -lt ~/Maildir/new|grep rapiq|head -1 ### 着信確認
-rw------- 1 user user  406 May 17 09:46 1621212367.26960_1.rapiq

user@rapiq:~ $ cat ~/Maildir/new/1621212367.26960_1.rapiq
Received: from user by rapiq with local (Exim 4.92)
	(envelope-from <user@rapiq>)
	id 1liROZ-00070k-86
	for user@rapiq.localdom.jp; Mon, 17 May 2021 09:46:07 +0900
Subject: Test
To: <user@rapiq.localdom.jp>
X-Mailer: mail (GNU Mailutils 3.5)
Message-Id: <E1liROZ-00070k-86@rapiq>
From: RDH_Install <user@rapiq>
Date: Mon, 17 May 2021 09:46:07 +0900

from rapiq Mon 17 May 09:46:02 JST 2021

(その2)に続く。https://qiita.com/borg5618/items/114d4c39befb97f38dba

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?