반응형

오늘은 라즈베리 파이에서 메일서비스 세팅을 Gmail 의 메일 서비스를 대신 사용하는 방법을 알아봤습니다.


저처럼 구지 라즈베리파이에서 메일 서버를 세팅 및 운영할 필요도 없지만, 사용하면서 메일 서비스를 통한 이메일을 보내고 싶을 때 사용하기 딱 좋네요.

(출처 : http://www.sbprojects.com/projects/raspberrypi/exim4.php)


1) 방법은 간단한 Message Transfer Agent 인 SSMTP 설치로 시작됩니다. 아래 맨 윗줄 블록 된 명령어를 쳐서 SSMTP 를 설치합니다.


pi@raspberrypi ~ $ sudo apt-get install ssmtp mailutils mpack


Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
  guile-1.8-libs libgnutls-openssl27 libgsasl7 libmailutils4 libntlm0
  mailutils-common
Suggested packages:
  mailutils-mh mailutils-doc mail-transport-agent inews
The following NEW packages will be installed:
  guile-1.8-libs libgnutls-openssl27 libgsasl7 libmailutils4 libntlm0
  mailutils mailutils-common mpack ssmtp
0 upgraded, 9 newly installed, 0 to remove and 24 not upgraded.
Need to get 3,705 kB of archives.
After this operation, 8,760 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libgnutls-openssl27 armhf 2.12.20-8+deb7u3 [218 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main guile-1.8-libs armhf 1.8.8+1-8 [722 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libntlm0 armhf 1.2-1 [19.3 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libgsasl7 armhf 1.8.0-2 [220 kB]
Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mailutils-common all 1:2.99.97-3 [795 kB]
Get:6 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libmailutils4 armhf 1:2.99.97-3 [841 kB]
Get:7 http://mirrordirector.raspbian.org/raspbian/ wheezy/main ssmtp armhf 2.64-7 [55.1 kB]
Get:8 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mailutils armhf 1:2.99.97-3 [796 kB]
Get:9 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mpack armhf 1.6-8 [38.4 kB]
Fetched 3,705 kB in 5s (685 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libgnutls-openssl27:armhf.
(Reading database ... 81693 files and directories currently installed.)
Unpacking libgnutls-openssl27:armhf (from .../libgnutls-openssl27_2.12.20-8+deb7u3_armhf.deb) ...
Selecting previously unselected package guile-1.8-libs.
Unpacking guile-1.8-libs (from .../guile-1.8-libs_1.8.8+1-8_armhf.deb) ...
Selecting previously unselected package libntlm0.
Unpacking libntlm0 (from .../libntlm0_1.2-1_armhf.deb) ...
Selecting previously unselected package libgsasl7.
Unpacking libgsasl7 (from .../libgsasl7_1.8.0-2_armhf.deb) ...
Selecting previously unselected package mailutils-common.
Unpacking mailutils-common (from .../mailutils-common_1%3a2.99.97-3_all.deb) ...
Selecting previously unselected package libmailutils4.
Unpacking libmailutils4 (from .../libmailutils4_1%3a2.99.97-3_armhf.deb) ...
Selecting previously unselected package ssmtp.
Unpacking ssmtp (from .../ssmtp_2.64-7_armhf.deb) ...
Selecting previously unselected package mailutils.
Unpacking mailutils (from .../mailutils_1%3a2.99.97-3_armhf.deb) ...
Selecting previously unselected package mpack.
Unpacking mpack (from .../archives/mpack_1.6-8_armhf.deb) ...
Processing triggers for man-db ...
Setting up libgnutls-openssl27:armhf (2.12.20-8+deb7u3) ...
Setting up guile-1.8-libs (1.8.8+1-8) ...
Setting up libntlm0 (1.2-1) ...
Setting up libgsasl7 (1.8.0-2) ...
Setting up mailutils-common (1:2.99.97-3) ...
Setting up libmailutils4 (1:2.99.97-3) ...
Setting up ssmtp (2.64-7) ...
Setting up mailutils (1:2.99.97-3) ...
update-alternatives: using /usr/bin/frm.mailutils to provide /usr/bin/frm (frm) in auto mode
update-alternatives: using /usr/bin/from.mailutils to provide /usr/bin/from (from) in auto mode
update-alternatives: using /usr/bin/messages.mailutils to provide /usr/bin/messages (messages) in auto mode
update-alternatives: using /usr/bin/movemail.mailutils to provide /usr/bin/movemail (movemail) in auto mode
update-alternatives: using /usr/bin/readmsg.mailutils to provide /usr/bin/readmsg (readmsg) in auto mode
update-alternatives: using /usr/bin/dotlock.mailutils to provide /usr/bin/dotlock (dotlock) in auto mode
Setting up mpack (1.6-8) ...


2) /etc/ssmtp/ssmtp.conf 파일을 열어서 아래 세팅을 맞춰줍니다. YOU 를 사용자 이메일 로그인 이름으로 해줍니다.

mailhub=smtp.gmail.com:587 hostname=RPI'S HOST NAME AuthUser=YOU@gmail.com AuthPass=PASSWORD useSTARTTLS=YES

아래는 제 라즈베리파이에 설치된 SSMTP 컨픽 파일 입니다. 붉은색 화살표가 수정된 곳을 보여줍니다. 제 Gmail 의 로그인 이름과 암호는 지웠습니다.




3) 파일 내 세팅이 완료 되면, 저장한 뒤 메일 보내기를 테스트 합니다.

<PHP 메일 테스트>

<?php

$message = $_SERVER['HTTP_USER_AGENT'];
mail('yobine@tistory.com', 'You have got mail', $message, 'RaspberryPI@house');

?>


4) 도착 메일입니다.


이렇게 하여 간단하게 이메일을 라즈베리파이 의 웹서비스에서 보낼 수 있게 되었습니다.  :)

반응형

+ Recent posts