ํ์ฉ ๊ธฐ์ค:
์ฐธ๊ณ :
์๋ ํ์ธ์ @thinkingserious!
์ฌํด์ ๋ค ๋ฒ์งธ PR์ ์ฐพ์ผ๋ ค๊ณ ํฉ๋๋ค. #hacktoberfest ๋ ์ ํ์ ๋ดค๋๋ฐ ํ๋ฒ ์๋ํด๋ณด๊ณ ์ถ์ต๋๋ค.
๋๋ Sendgrid๋ฅผ ์ฌ์ฉํ ์ ์ด ์๊ธฐ ๋๋ฌธ์ ์ด๋์๋ถํฐ ์์ํ๊ณ ๋ฌธ์ ๋ฅผ ์ดํด ํด์ผํ๋์ง ์กฐ๊ธ ์์ด ๋ฒ๋ ธ์ต๋๋ค. ๋ฉ์ผ ๋์ฐ๋ฏธ๋ฅผ ํ์ฅํ๋ ๊ฒ์ ๋๊น? ๋จ์ผ ๋ฉ์ผ์ ๋ณด๋ด๋ ๋ฐฉ๋ฒ์ ๋ฌธ์ํํฉ๋๊น? ๋๋ ๋ช ๊ฐ์ง ์ค๋ช ์ ์ํฉ๋๋ค.
๊ฑด๋ฐฐ, ํ๋ธ๋ก.
์๋ ํ์ธ์ Pablo,
๋จผ์ ์ ์ฒด "Mail Helper Enhancement (v3 mail / send)" ํ๋ก์ ํธ ๋ฅผ ๊ฒํ ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ฉ์ผ ๋์ฐ๋ฏธ๋ฅผ ๋ฆฌํฉํฐ๋งํ์ฌ์ด ํ๋ก์ ํธ์ ์ ์ ๋ ์ฌ์ฉ ์ฌ๋ก๋ฅผ ๊ฐ๋ฅํ ํ ๊ฐ๋จํ๊ฒ ์คํํ๊ณ ์ํฉ๋๋ค.
์๋ฅผ ๋ค์ด ์ด์ ๋จ์ผ ์ด๋ฉ์ผ์ ๋ณด๋ด๋ hello world๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
var helper = require('sendgrid').mail;
var from_email = new helper.Email('[email protected]');
var to_email = new helper.Email('[email protected]');
var subject = 'Hello World from the SendGrid Node.js Library!';
var content = new helper.Content('text/plain', 'Hello, Email!');
var mail = new helper.Mail(from_email, subject, to_email, content);
var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
var request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: mail.toJSON(),
});
sg.API(request, function(error, response) {
console.log(response.statusCode);
console.log(response.body);
console.log(response.headers);
});
์ด๋ฅผ ๊ฐ์ ํ๋ ํ ๊ฐ์ง ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
var mail = require('sendgrid').mail;
mail.AddFromEmail('[email protected]');
mail.AddToEmail('[email protected]');
mail.AddSubject('Hello World from the SendGrid Node.js Library!');
mail.AddContent('text/plain', 'Hello Email!');
var sendgrid = require('sendgrid')(process.env.SENDGRID_API_KEY);
sendgrid.send(mail, function(error, response) {
if(error) {
console.log(error.message);
console.log(error.response.statusCode);
console.log(error.response.body);
console.log(error.response.headers);
} else {
console.log(response);
}
});
์ข์ต๋๋ค. ์์ ํ ๋ฆฌํฉํฐ๋ง์ ๋๋ค. ์๊ฐ์๋ด์ด ์๋ํด ๋ณด๋๋กํ๊ฒ ์ต๋๋ค.
์งํ ์ค : # 378
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋ ํ์ธ์ Pablo,
๋จผ์ ์ ์ฒด "Mail Helper Enhancement (v3 mail / send)" ํ๋ก์ ํธ ๋ฅผ ๊ฒํ ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ฉ์ผ ๋์ฐ๋ฏธ๋ฅผ ๋ฆฌํฉํฐ๋งํ์ฌ์ด ํ๋ก์ ํธ์ ์ ์ ๋ ์ฌ์ฉ ์ฌ๋ก๋ฅผ ๊ฐ๋ฅํ ํ ๊ฐ๋จํ๊ฒ ์คํํ๊ณ ์ํฉ๋๋ค.
์๋ฅผ ๋ค์ด ์ด์ ๋จ์ผ ์ด๋ฉ์ผ์ ๋ณด๋ด๋ hello world๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
์ด๋ฅผ ๊ฐ์ ํ๋ ํ ๊ฐ์ง ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.