SendGrid 통합 추가
SendGrid는 트랜잭션 및 마케팅 이메일을 전달하기 위한 클라우드 기반 서비스입니다. 이 통합을 연결하면 애플리케이션에서 프로그래밍 방식으로 이메일을 보낼 수 있습니다(예: 환영 이메일, 비밀번호 재설정 또는 알림).
구성 단계
섹션 제목: “구성 단계”통합 목록에서 SendGrid를 선택하면 구성 모달이 나타납니다. 연결을 설정하려면 다음 자격 증명을 제공해야 합니다:
1. API 키
섹션 제목: “1. API 키”SendGrid 계정 내에서 생성된 인증 토큰입니다.
- 입력: 비공개 SendGrid API 키를 텍스트 필드에 붙여넣으세요.
- 도움말: 키가 없는 경우 모달에 제공된 “API 키를 찾을 위치는?” 링크를 클릭하여 생성 방법에 대한 지침을 확인하세요.
2. 환경
섹션 제목: “2. 환경”이 통합의 환경 컨텍스트를 지정합니다.
- 입력: 환경 필드에 환경 식별자(예:
Production,Staging또는 특정 구성 태그)를 입력하세요.
연결 완료
섹션 제목: “연결 완료”필드가 입력되면:
- 상태 표시줄을 검토하세요(현재 Not Connected 표시).
- 오른쪽 하단의 검은색 Add 버튼을 클릭하여 자격 증명을 저장하고 통합을 활성화하세요.


SendGrid 통합 API 참조
섹션 제목: “SendGrid 통합 API 참조”SendGrid 구성
섹션 제목: “SendGrid 구성”SendGrid API 키 구성
섹션 제목: “SendGrid API 키 구성”특정 프로젝트 및 환경에 대한 SendGrid API 키를 구성합니다.
Mutation:
mutation { sendgrid_configureSendGrid ( apiKey: "SG._api_key_here" )}이메일 전송
섹션 제목: “이메일 전송”간단한 이메일 전송
섹션 제목: “간단한 이메일 전송”한 명 또는 여러 명의 수신자에게 이메일을 전송합니다.
Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail ( email: { from: { email: "sender@archie.com", name: "Sender Name" }, subject: "Test Email", to: { email: "recipient@gmail.com", name: "Recipient Name" }, content: { type: "text/html", value: "<h1>Hello World</h1><p>This is a test email.</p>" } } ) { messageId success }}Response:
{ "data": { "sendgrid_sendEmail": { "messageId": "sent-1234567890", "success": true } }}CC 및 BCC와 함께 이메일 전송
섹션 제목: “CC 및 BCC와 함께 이메일 전송”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail ( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] cc: [ { email: "cc@example.com" name: "CC Recipient" } ] bcc: [ { email: "bcc@example.com" } ] subject: "Email with CC and BCC" content: [ { type: "text/html" value: "<h1>Hello</h1><p>This email has CC and BCC recipients.</p>" } ] } ) { messageId success }}첨부 파일과 함께 이메일 전송
섹션 제목: “첨부 파일과 함께 이메일 전송”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Email with Attachment" content: [ { type: "text/html" value: "<h1>Hello</h1><p>Please find attached file.</p>" } ] attachments: [ { content: "SGVsbG8gV29ybGQ=" type: "text/plain" filename: "document.txt" disposition: "attachment" } ] } ) { messageId success }}참고: 첨부 파일의 content 필드는 Base64로 인코딩해야 합니다.
카테고리 및 태그와 함께 이메일 전송
섹션 제목: “카테고리 및 태그와 함께 이메일 전송”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Categorized Email" content: [ { type: "text/html" value: "<h1>Hello</h1>" } ] categories: ["transactional", "notification"] tags: ["important", "urgent"] } ) { messageId success }}예약된 이메일 전송
섹션 제목: “예약된 이메일 전송”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Scheduled Email" content: [ { type: "text/html" value: "<h1>Hello</h1>" } ] sendAt: "2025-12-25T10:00:00Z" } ) { messageId success }}사용자 정의 인수와 함께 이메일 전송
섹션 제목: “사용자 정의 인수와 함께 이메일 전송”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Email with Custom Args" content: [ { type: "text/html" value: "<h1>Hello</h1>" } ] customArgs: { orderId: "12345" userId: "67890" campaignId: "abc123" } } ) { messageId success }}대량 이메일 전송
섹션 제목: “대량 이메일 전송”여러 이메일 전송
섹션 제목: “여러 이메일 전송”Mutation:
mutation sendgrid_sendBulkEmail { sendgrid_sendBulkEmail( emails: { emails: [ { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient1@example.com" name: "Recipient 1" } ] subject: "Bulk Email 1" content: [ { type: "text/html" value: "<h1>Email 1</h1>" } ] } { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient2@example.com" name: "Recipient 2" } ] subject: "Bulk Email 2" content: [ { type: "text/html" value: "<h1>Email 2</h1>" } ] } ] } ) { messageIds success }}Response:
{ "data": { "sendgrid_sendBulkEmail": { "messageIds": ["sent-1234567890", "sent-1234567891"], "success": true } }}템플릿을 사용한 이메일 전송
섹션 제목: “템플릿을 사용한 이메일 전송”동적 템플릿을 사용하여 이메일 전송
섹션 제목: “동적 템플릿을 사용하여 이메일 전송”Mutation:
mutation sendgrid_sendTemplate { sendgrid_sendTemplate( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] templateId: "d-1234567890abcdef" substitutions: { name: "John Doe" orderNumber: "12345" totalAmount: "$99.99" } } ) { messageId success }}Response:
{ "data": { "send grid_sendTemplate": { "messageId": "sent-1234567890", "success": true } }}연락처 관리
섹션 제목: “연락처 관리”연락처 추가
섹션 제목: “연락처 추가”Mutation:
mutation sendgrid_addContact { sendgrid_addContact( contact: { email: "newcontact@example.com" firstName: "John" lastName: "Doe" customFields: { company: "Acme Corp" phone: "+1234567890" position: "Developer" } listIds: ["list-id-1", "list-id-2"] } )}Response:
{ "data": { "sendgrid_addContact": true }}연락처 업데이트
섹션 제목: “연락처 업데이트”Mutation:
mutation sendgrid_updateContact { sendgrid_updateContact( contact: { email: "existing@example.com" firstName: "Jane" lastName: "Smith" customFields: { company: "New Company" phone: "+0987654321" } } )}Response:
{ "data": { "sendgrid_updateContact": true }}연락처 삭제
섹션 제목: “연락처 삭제”Mutation:
mutation sendgrid_deleteContact { sendgrid_deleteContact( email: "contact@example.com" )}Response:
{ "data": { "sendgrid_deleteContact": true }}분석 및 통계
섹션 제목: “분석 및 통계”이메일 통계 가져오기
섹션 제목: “이메일 통계 가져오기”Query:
query sendgrid_getEmailStats { sendgrid_getEmailStats ( startDate: "2025-01-01" endDate: "2025-01-31" ) { opens clicks bounces spamReports delivered startDate endDate }}Response:
{ "data": { "sendgrid_getEmailStats": { "opens": 150, "clicks": 75, "bounces": 5, "spamReports": 2, "delivered": 1000, "startDate": "2025-01-01T00:00:00Z", "endDate": "2025-01-31T00:00:00Z" } }}이메일 검증
섹션 제목: “이메일 검증”Query:
query sendgrid_validateEmail { sendgrid_validateEmail ( email: "test@example.com" ) { valid score local domain reason suggestions }}Response (SendGrid Premium 사용):
{ "data": { "sendgrid_validateEmail": { "valid": true, "score": 0.95, "local": "test", "domain": "example.com", "reason": "", "suggestions": [] } }}Response (기본 검증 - SendGrid Premium을 사용할 수 없는 경우):
{ "data": { "sendgrid_validateEmail": { "valid": true, "score": 0.8, "local": "test", "domain": "example.com", "reason": "Basic validation (SendGrid premium validation not available)", "suggestions": [] } }}참고: SendGrid 이메일 검증 엔드포인트(/v3/validations/email)는 특별한 권한이 필요하며 모든 계정에서 사용 가능하지 않을 수 있습니다. API 키가 이 엔드포인트에 액세스할 수 없는 경우(오류 403), 시스템은 자동으로 정규 표현식 기반 기본 검증을 대체 수단으로 사용합니다.
변수를 사용한 완전한 예제
섹션 제목: “변수를 사용한 완전한 예제”GraphQL 변수를 사용한 예제
섹션 제목: “GraphQL 변수를 사용한 예제”Request:
{ "query": "mutation SendEmail($email: EmailInput!) { sendgrid_sendEmail(email: $email) { messageId success } }", "variables": { "email": { "from": { "email": "sender@example.com", "name": "Sender Name" }, "to": [ { "email": "recipient@example.com", "name": "Recipient Name" } ], "subject": "Test Email", "content": [ { "type": "text/html", "value": "<h1>Hello World</h1>" } ] } }}오류 처리
섹션 제목: “오류 처리”오류 예제
섹션 제목: “오류 예제”Request:
{ "query": "mutation { sendgrid_sendEmail(email: { from: { email: \"invalid\" }, to: [], subject: \"Test\", content: [] }) { messageId success } }"}Response Error:
{ "errors": [ { "message": "validation error: at least one recipient is required", "path": ["sendgrid_sendEmail"] } ], "data": null}일반적인 오류
섹션 제목: “일반적인 오류”-
프로젝트 ID 누락:
{"errors": [{"message": "project ID is required in context"}]} -
구성을 찾을 수 없음:
{"errors": [{"message": "sendgrid configuration not found for project: xxx, environment: master"}]} -
API 키 무효:
{"errors": [{"message": "sendgrid API error: status 401, body: ..."}]}
Webhooks
섹션 제목: “Webhooks”Webhooks 엔드포인트
섹션 제목: “Webhooks 엔드포인트”Webhooks 엔드포인트는 다음 위치에서 사용할 수 있습니다:
- HTTP:
POST http://localhost:8080/webhooks/sendgrid - Lambda:
POST /webhooks/sendgrid
SendGrid 구성
섹션 제목: “SendGrid 구성”- SendGrid Dashboard > Settings > Mail Settings > Event Webhook으로 이동
- URL 구성:
https://your-domain.com/webhooks/sendgrid - 수신할 이벤트 선택
- 환경 변수
WEBHOOK_VERIFICATION_KEY에 검증 키 구성
지원되는 이벤트
섹션 제목: “지원되는 이벤트”processed: 이메일 처리됨delivered: 이메일 전달됨opened: 이메일 열림clicked: 링크 클릭됨bounce: 이메일 반송됨dropped: 이메일 삭제됨spamreport: 스팸 신고됨unsubscribe: 구독 취소