Sendgrid-nodejs: λͺ¨λ“  μ‚¬λžŒμ΄ TO ν—€λ”μ—μ„œ μžμ‹ μ˜ 이메일 만 λ³Ό 수 μžˆλ„λ‘ μ—¬λŸ¬ μˆ˜μ‹ μžμ—κ²Œ 이메일을 λ³΄λƒ…λ‹ˆλ‹€.

에 λ§Œλ“  2017λ…„ 01μ›” 06일  Β·  4μ½”λ©˜νŠΈ  Β·  좜처: sendgrid/sendgrid-nodejs

μ•ˆλ…•ν•˜μ„Έμš”,

λͺ¨λ“  μˆ˜μ‹ μžκ°€λ°›λŠ” μ‚¬λžŒ μƒμžμ—μ„œ μžμ‹ μ˜ μ£Όμ†Œ 만 λ³Ό 수 μžˆλ„λ‘ Web API v3λ₯Ό μ‚¬μš©ν•˜μ—¬ ν•œ 번의 API 호좜둜 κ°œλ³„μ μœΌλ‘œ 메일을 보내렀면 μ–΄λ–»κ²Œν•΄μ•Όν•©λ‹ˆκΉŒ? ν˜„μž¬ nodejs, Web API v3 및 sendgrid 쒅속성을 μ‚¬μš©ν•˜μ—¬ 메일을 보내고 μžˆμ§€λ§Œ λ¬Έμ œλŠ” μ‚¬μš©μžκ°€λ°›λŠ” μ‚¬λžŒ μƒμžμ— 전체 μˆ˜μ‹ μž λͺ©λ‘μ„ κ°€μ Έ μ˜€λŠ” κ²ƒμž…λ‹ˆλ‹€. μš”μ²­μ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

var request = sg.emptyRequest({
        method: 'POST',
        path: '/v3/mail/send',
        body: {
            personalizations: [
                {
                    to: recepientEmails,
                    substitutions: emailTemplate.substitutions
                }
            ],
            from: {
                email: '[email protected]',
                name: 'Dorotea from AWW'
            },
            template_id: emailTemplate.template_id,
            categories: emailTemplate.categories
        }
    });

Web API v2μ—μ„œλŠ” x-smtp 헀더λ₯Ό μ‚¬μš©ν•˜μ—¬ 이메일이 μ—¬κΈ° ν‘œμ˜ 첫 번째 ν–‰μ—μ„œ 각 μˆ˜μ‹ μžμ—κ²Œ κ°œλ³„μ μœΌλ‘œ μ „μ†‘λ˜λ„λ‘ν•΄μ•Όν•œλ‹€κ³  μ½μ—ˆμŠ΅λ‹ˆλ‹€.
https://sendgrid.com/docs/API_Reference/Web_API/mail.html

그리고 μ—¬κΈ°μ—μ„œ 단 ν•˜λ‚˜μ˜ μš”μ²­μ„ μ‚¬μš©ν•˜μ—¬ Web API v3μ—μ„œ SMTPλ₯Ό μ‚¬μš©ν•˜λŠ” Web API v2의 λͺ¨λ“  μž‘μ—…μ„ μˆ˜ν–‰ ν•  수 μžˆλ‹€λŠ” 것을 μ½μ—ˆμŠ΅λ‹ˆλ‹€.
https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html

마무리λ₯Ό μœ„ν•΄ Web API v3둜 ν•˜λ‚˜μ˜ API ν˜ΈμΆœμ„ λ§Œλ“€μ–΄ μ—¬λŸ¬ μ£Όμ†Œλ‘œ 이메일을 보내고 λͺ¨λ“  이메일이 TO 헀더에 ν•΄λ‹Ή μˆ˜μ‹ μž 이메일 만 κ°–κΈ°λ₯Ό μ›ν•©λ‹ˆλ‹€.

λͺ¨λ‘ 졜고,
Zvonimir

help wanted question

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

μ•ˆλ…•ν•˜μ„Έμš” @ zvone187 ,

이 μž‘μ—…μ„ μˆ˜ν–‰ν•˜λŠ” 방법을 이미 μ•Œμ•„ λƒˆλŠ”μ§€ λͺ¨λ₯΄κ² μ§€λ§Œ 이것은 λ‹¬μ„±ν•˜λ €λŠ” 것과 κ°™μŠ΅λ‹ˆλ‹€.

λ°›λŠ” μ‚¬λžŒλ§ˆλ‹€ λ‹€λ₯Έ 개인 섀정을 μΆ”κ°€ν•΄μ•Όν•©λ‹ˆλ‹€. μ½”λ“œμ—μ„œ λ‹€μŒκ³Ό 같이 λ²ˆμ—­λ˜μ–΄μ•Όν•©λ‹ˆλ‹€.

// This assumes every recipient gets the same substitutions. If not, just add the right substitution for each email
const personalizations = recipientEmails.map(email => ({
    to: [{ email }],
    substitutions: emailTemplate.substitutions
}));
const request = sg.emptyRequest({
    method: 'POST',
    path: '/v3/mail/send',
    body: {
        personalizations,
        from: {
            email: '[email protected]',
            name: 'Dorotea from AWW'
        },
        template_id: emailTemplate.template_id,
        categories: emailTemplate.categories
    }
});

ν•œ 번의 μš”μ²­μœΌλ‘œ 보낼 μˆ˜μžˆλŠ” μˆ˜μ‹ μž μˆ˜μ— λŒ€ν•œ ν˜„μž¬ μ œν•œμ΄ 무엇인지 잘 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€.

λͺ¨λ“  4 λŒ“κΈ€

μ•ˆλ…•ν•˜μ„Έμš” @ zvone187 ,

이 μž‘μ—…μ„ μˆ˜ν–‰ν•˜λŠ” 방법을 이미 μ•Œμ•„ λƒˆλŠ”μ§€ λͺ¨λ₯΄κ² μ§€λ§Œ 이것은 λ‹¬μ„±ν•˜λ €λŠ” 것과 κ°™μŠ΅λ‹ˆλ‹€.

λ°›λŠ” μ‚¬λžŒλ§ˆλ‹€ λ‹€λ₯Έ 개인 섀정을 μΆ”κ°€ν•΄μ•Όν•©λ‹ˆλ‹€. μ½”λ“œμ—μ„œ λ‹€μŒκ³Ό 같이 λ²ˆμ—­λ˜μ–΄μ•Όν•©λ‹ˆλ‹€.

// This assumes every recipient gets the same substitutions. If not, just add the right substitution for each email
const personalizations = recipientEmails.map(email => ({
    to: [{ email }],
    substitutions: emailTemplate.substitutions
}));
const request = sg.emptyRequest({
    method: 'POST',
    path: '/v3/mail/send',
    body: {
        personalizations,
        from: {
            email: '[email protected]',
            name: 'Dorotea from AWW'
        },
        template_id: emailTemplate.template_id,
        categories: emailTemplate.categories
    }
});

ν•œ 번의 μš”μ²­μœΌλ‘œ 보낼 μˆ˜μžˆλŠ” μˆ˜μ‹ μž μˆ˜μ— λŒ€ν•œ ν˜„μž¬ μ œν•œμ΄ 무엇인지 잘 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€.

@iamtheib 응닡에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€. Sengridλ‘œλΆ€ν„° 닡변을 λ°›μ•˜μŠ΅λ‹ˆλ‹€. λ„€, μ •ν™•νžˆν•΄μ•Ό ν•  μΌμ΄μ—ˆμŠ΅λ‹ˆλ‹€.

μž‘λ™ν•˜μ§€λ§Œ μˆ˜μ‹ μžλ§ˆλ‹€ λ‹€λ₯Έ 첨뢀 νŒŒμΌμ„ λ³΄λ‚΄λŠ” 것은 μ–΄λ–»μŠ΅λ‹ˆκΉŒ?
ν…œν”Œλ¦Ώμ€ κ°™μ§€λ§Œ 개인 섀정이 λ‹€λ₯΄κ³  μ‚¬μš©μžλ§ˆλ‹€ λ‹€λ₯Έ 첨뢀 νŒŒμΌμ„ μ‚¬μš©ν•˜μ—¬ μ—¬λŸ¬ 이메일을 λ³΄λ‚΄μ•Όν•©λ‹ˆλ‹€.

@iamtheib ,

도와 μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€! 이 양식을 μž‘μ„±ν•΄ μ£Όμ‹œλ©΄ μŠ€μ›©μ„ 보내 λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€. :)

λ§ˆμŒμ„ λ‹΄μ•„,

Elmer

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰