開発者向けリソース
SGHMailとの連携に必要なすべてのリソース
SDKs & ライブラリ
インストール:
npm install @sghmail/sdkコード例
メール送信
import { SGHMail } from '@sghmail/sdk';
const client = new SGHMail({
apiKey: process.env.SGHMAIL_API_KEY
});
await client.messages.send({
to: 'recipient@example.com',
from: 'sender@yourdomain.xyz',
subject: 'Hello from SGHMail',
text: 'This is a test message.'
});Webhook受信
import express from 'express';
import { verifyWebhook } from '@sghmail/sdk';
app.post('/webhook', (req, res) => {
const isValid = verifyWebhook(
req.body,
req.headers['x-sghmail-signature'],
process.env.WEBHOOK_SECRET
);
if (isValid) {
const { event, data } = req.body;
console.log('Email received:', data.subject);
}
res.status(200).send('OK');
});CLI ツール
コマンドラインからSGHMailを操作できます。
# インストール
npm install -g @sghmail/cli
# ログイン
sghmail login
# メール送信
sghmail send --to user@example.com --subject "Hello"