Programming Tips

smtp 호스트로 메일 보내는 golang 소스

rfc5322를 만족하는 golang smtp 작성

golang의 "net/smtp" 라이브러리를 사용해서 메일을 gmail로 전송하다 보면 아래와 같은 에러메시지를 받게된다.

최근 매일 자동으로 설정이 필요한 부분이 있어서 "오늘이 공휴일" 인지 확인하는 부분이 필요했다.
이걸 자동으로 확인해주는 것이 있을지 확인해보는 중에 좋은 것 있어 정리한다.

Python holidays 패키지
  - Github : https://github.com/dr-prodigy/python-holidays

설치

% pip install holidays

 

사용법

go(golang) 1.16 버전 이후, go.mod를 사용하도록 강제되었다.
이런 이유로 1.15 버전으로 만들어진 패키지를 실행하기 위해서 패키지를 설치하면 아래와 같은
오류가 잔뜩 발생한다.

 % go run read_config.go
read_config.go:4:5: no required module provides package gopkg.in/gcfg.v1: go.mod file not found in current directory or any parent directory; see 'go help modules'

 

그렇다고 필요 패키지를 설치하려면 오류가 발생해서 workaround로 아래 설정해주려니 잠시는 되어도 호환성 문제가 발생한다.

급하게 파일을 업로드하는 경우가 필요해서 간단하게 작성한 php 업로드 프로그램입니다.

 

1. 업로드 html 구성

  - upload.html

<!DOCTYPE html>
<html>
<body>

<form action="uploader.php" method="post" enctype="multipart/form-data">
    Select File:
    <input type="file" name="fileToUpload"/>
    <input type="submit" value="Upload file" name="submit"/>
</form>

</body>
</html>

 

2. upload file 처리를 위한 php 파일

  - uploader.php