npm&github集成:簡化的電子郵件與node.js
>密鑰功能:
>先決條件:
入門:
1。安裝:
使用npm:
<code class="language-bash">npm install job-email-sender</code>
<code class="language-bash">yarn add job-email-sender</code>
2。配置:
>將以下配置添加到您的主要應用程序文件:
<code class="language-javascript">const emailConfig = { service: 'your-email-service', // e.g., 'gmail', 'yahoo' user: 'your-email@example.com', // Your email address pass: 'your-email-app-password', // Your email app password (not your regular password!) name: 'Your Display Name' };</code>
重要說明:
your-email@example.com
Your Display Name
字段應與您的電子郵件提供商(Gmail,Yahoo等)匹配。 service
pass
yahoo:
> javaScript:
> typescript:
><code class="language-javascript">const { EmailSender } = require('job-email-sender');</code>
發送電子郵件:
<code class="language-typescript">import { EmailSender } from 'job-email-sender';</code>
重要的考慮因素:
<code class="language-javascript">const emailSender = new EmailSender(emailConfig); const contacts = [{ email: 'receiver-name@example.com', name: 'Don' }]; const message = 'Hello ${name}, this is your email content!'; // HTML support: 'Hello ${name}, <p><b>this</b> is a test email!</p>' const subject = 'Your Email Subject'; emailSender.sendEmails(contacts, message, subject) .then((message) => console.log(message)) .catch((error) => console.error(error));</code>
附件:>支持電子郵件附件的支持。
以上是電子郵件發送服務的詳細內容。更多資訊請關注PHP中文網其他相關文章!