사실 Gmail API를 사용해서 메일을 보내면 되는 태스크인데, api에 종속되지 않고 메일을 보낼 수 있는 방법이어서 시도해봤다. 서버 없이 프론트에서 form을 이용해 메일을 보낼 수 있는 방법이라 알아두면 유용할 것 같다.
Google apps script
본인 계정의 지메일로 구글 스프레드 시트를 deploy 함. (구글 드라이브에서 확인 가능)
https://docs.google.com/spreadsheets/… → Tools 탭 → Script Editor
* 테스트 후 Manage Deployment
에서 권한 Only Myself 로 설정! *
보내는 사람:
Google Apps
를 deploy한 사람받는 사람:
mailData.receiver
(내 form의name="receiver"
이 받는 사람이기 때문)it defaults to the email provided by the form’s data attribute
var mailData = e.parameters
=== FormData bodye
: formDatae
is the data received from the POSTe.parameters
=== mailData :formData.data
shorter name for form data
1
2
3
4
5
6
7
8
9/*
formData // e
data // e.parameters
{"receiver": "", ...}
*/
"data":"{\\"receiver\\":[\\"aaa@gmail.com\\"],\\"title\\":[\\"z\\"],\\"message\\":[\\"q\\"]}"
위는 내 폼 형식에 맞게 중요한 부분만 적어두었는데, 단계별로 진행해보고 싶다면 밑 레퍼런스를 참고하면 된다.