-1
sendgrid를 사용하여 여러 수신자에게 전자 메일을 보낼 때 문제가 발생했습니다. 대체 항목을 추가 할 때 공백 값이 나타납니다.node.js 여러 수신자가있는 sendgrid가 대체 문자를 추가 할 때 공백 값을 받음
기술
- Node.js를
- sendgrid (V2)
==== 내 샘플 코드 (Node.js를) ====
const SENDGRID_API_KEY = 'KEY'
const sendgrid = require('sendgrid')(SENDGRID_API_KEY)
function sendEmailToSupport() {
const email = new sendgrid.Email({
from: '[email protected]',
to: ['[email protected]', '[email protected]', '[email protected]']
html: '<div>test = :test</div>',
subject: 'dummy'
})
email.addSubstitution(':test', 'ddddddddddddd')
sendgrid.send(email, (err, response) => {
if (err) {
console.log(err)
} else {
console.log('Yay! Our templated email has been sent')
}
})
}
module.exports = {
sendEmailToSupport
}
====== 결과 ======
[email protected] 올바른 내용으로 빈 값
test = ddddddddddddd
[email protected], [email protected] GET 이메일을 이메일을 얻을
test =
는 첫 번째 이메일처럼 보인다 email.to
배열에 올바른 내용을 가져오고 나머지는 빈 데이터를 얻습니다.
sendgrid 웹 관리자에서 오류가 발생하지 않습니다.
이 문제를 해결하는 방법은 무엇입니까?
감사 후 sendgrid LIB를 분석, 나는이 줄
email.addSubstitution(':test', new Array(email.to.length).fill('ddddddddddddd'))
을 편집하여 이제 해결책을 발견