Skip to Content
한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
book

한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것

by 한선용, 이선 브라운
May 2021
Beginner to intermediate
448 pages
9h 47m
Korean
Hanbit Media, Inc.
Content preview from 한 권으로 끝내는 Node & Express(2판): 모던 웹을 위한 서버 사이드 자바스크립트의 모든 것
423
부록
D
이메일 전송
D.1.1
메일 전송
수신자 한 명에게 메일을 보낼 때는 다음과 같이 보냅니다.
/* 초기화 */
const msg = {
to: ‘joecustomer@gmail.com’,
from: ‘”Meadowlark Travel” <info@meadowlarktravel.com>’,
// 발신자 인증을 잊지 마세요.
subject: ‘Your Meadowlark Travel Tour’,
text: ‘Thank you for booking your trip with Meadowlark Travel.’,
};
async function send (msg) {
try {
const result = await transport.sendMail(msg)
console.log(‘mail sent successfully: ‘, result)
// API 응답은 상당히 장황한 편이므로 필요한 것만 보세요.
} catch(err) {
console.log(‘could not send mail: ‘ + err.message)
}
}
send(msg)
저자가 언급하지 않았는데
async
/
await
는 전역 스코프에서 허용되지 않으므로 위 예제와 같
이 래퍼를 만들어 사용해야 합니다. 메일에 해당하는 객체를 함수 안에 쓰는 것보다는 위 예제
처럼 분리하는 편이 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한 권으로 끝내는 Node & Express: 웹사이트 구축을 위한 서버 사이드 자바스크립트

한성용, 이선 브라운

Publisher Resources

ISBN: 9791162244227