티스토리 뷰
설치 방법
macOS Host 에 설정
mac 터미널에서 mailhog 를 brew 로 설치:
brew install mailhog
설치를 완료하였다면 mac 시작시 실행되도록 서비스 시작 명령:
brew services start mailhog
mailhog 가 제대로 실행되었는지 웹콘솔 접속:
http://127.0.0.1:8025
go 언어 설치:
brew install go
go 환경변수 설정:
export GO=/usr/local/Cellar/go/1.2/libexec
export PATH=$GO/bin:$PATH
export GOROOT=$GO
export GOPATH=/Users/user-id/go
export PATH=$PATH:$GOPATH/bin
go 를 사용하여 mhsendmail 설치:
go get github.com/mailhog/mhsendmail
mkdir -p $GOPATH
cp ~/go/bin/mhsendmail /usr/bin/mhsendmail
PHP 에서 mail() 함수로 메일 발송시 mailhog 가 작동되도록
php.ini 내에 있는 sendmail_path = 부분 수정:
sendmail_path = "/usr/bin/mhsendmail --smtp-addr localhost:1025"
터미널에서 메일 송신 테스트 명령:
php -r 'mail("foo@example.com", "test", time(), "From: Mailhog <mailhog@example.com>");'
mailhog 웹콘솔 접속하여 메일함 확인:
http://127.0.0.1:8025
php-fpm 데몬을 docker 컨테이너로 띄운 경우 설정
위 mac Host 에 설정 과정 중 go 언어 설치 과정부터 다름.
Dockerfile 수정:
ENV GOPATH /root/go
RUN apt-get install -y git golang-go && mkdir -p $GOPATH && go get github.com/mailhog/mhsendmail && cp ~/go/bin/mhsendmail /usr/bin/mhsendmail
host 와 volume binding 한 php.ini 파일 수정:
sendmail_path = "/usr/bin/mhsendmail --smtp-addr host.docker.internal:1025"
--smtp-addr 옵션 값으로 지정한 호스트명을 mac Host 로 설정하였음.
만약 mailhog 를 동일 Host 에 다른 docker 컨테이너로 띄운 경우 그 컨테이너의 호스트명을 지정해 주면 됨.
Reference
- https://github.com/maijs/homebrew-mailhog
- https://www.lesstif.com/pages/viewpage.action?pageId=61906418
- http://reachlab-kr.github.io/jekyll/update/2015/06/20/OSX-Golang-DevEnv.html
'웹프로그래밍 > PHP' 카테고리의 다른 글
PHP 9.0의 새로운 기능과 변화 미리보기 (2) | 2025.04.03 |
---|---|
Lavavel Valet 개별 사용자 환경설정 디렉토리 (0) | 2019.02.13 |
.composer/vendor/ 패키지 오류 발생시 (0) | 2018.11.29 |
[책 후기] 바쁜 팀장님 대신 알려주는 신입 PHP 개발자 안내서 (0) | 2018.02.04 |
Laravel 4.2 queue + redis + sqlite 구성 셋팅 (2) | 2017.08.30 |
- Total
- Today
- Yesterday
- mssql
- Debug
- centos
- Android
- IE
- Mac
- 워드프레스
- CSS
- IOS
- laravel
- classic asp
- Prototype
- iphone
- nodejs
- macos
- 안드로이드
- Docker
- iis
- javascript
- Wordpress
- JSON
- git
- nginx
- JQuery
- 한글
- PHP
- ASP
- API
- Linux
- sencha touch
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |