试图在 nodejs 中从上到下找到一个清晰的简单电子邮件包和示例

trying to find a clear simple email package and example top to bottom, in nodejs

我正在尝试构建/寻找一个解决方案,让我的 nodejs 将电子邮件发送到我通过 HTTP.POST() 获得的特定地址。 我的需求很简单——我只需要在每次有人打电话给我的 http.post() 时针对特定地址发送一封简短的电子邮件。 我也很乐意发送一个 HTML 的小文件作为附件,但如果它很复杂,我会简单地将 html/text 解析到邮件中(无论如何它是一个短文本)。

问题是我不明白创建这样一个模块需要什么。

  1. 我试过玩 'mailcomposer' ,但它似乎只能用来创建一个 不发送邮件的格式。

  2. 我看'nodemailer'用起来差不多要$1,000,所以也不行。

  3. 也尝试将 'mailover' 与 gmail 帐户一起使用(没什么特别的 - 就像在他们的 example 中一样),但代码是 运行,并且没有发送电子邮件/ 没有警告 / 没有错误 / 什么都没有... 不确定它是否是工作模块。

任何想法在哪里可以找到如何在 NODEJS 中使用邮件程序的简单明了的分步示例?我对电子邮件协议一无所知,这就是为什么我也在寻找一个循序渐进的例子。

提前致谢:-)

你可以使用 Mandrill

https://mandrillapp.com/api/docs/index.nodejs.html

这就是你发布它的方式,现在你可以做一些邮寄:

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY');
var message = {
    "html": "<p>Example HTML content</p>",
    "text": "Example text content",
    "subject": "example subject",
    "from_email": "message.from_email@example.com",
    "from_name": "Example Name",
    "to": [{
            "email": "recipient.email@example.com",
            "name": "Recipient Name",
            "type": "to"
        }],
    "headers": {
        "Reply-To": "message.reply@example.com"
    },
    "important": false,
    "track_opens": null,
    "track_clicks": null,
    "auto_text": null,
    "auto_html": null,
    "inline_css": null,
    "url_strip_qs": null,
    "preserve_recipients": null,
    "view_content_link": null,
    "bcc_address": "message.bcc_address@example.com",
    "tracking_domain": null,
    "signing_domain": null,
    "return_path_domain": null,
    "merge": true,
    "merge_language": "mailchimp",
    "global_merge_vars": [{
            "name": "merge1",
            "content": "merge1 content"
        }],
    "merge_vars": [{
            "rcpt": "recipient.email@example.com",
            "vars": [{
                    "name": "merge2",
                    "content": "merge2 content"
                }]
        }],
    "tags": [
        "password-resets"
    ],
    "subaccount": "customer-123",
    "google_analytics_domains": [
        "example.com"
    ],
    "google_analytics_campaign": "message.from_email@example.com",
    "metadata": {
        "website": "www.example.com"
    },
    "recipient_metadata": [{
            "rcpt": "recipient.email@example.com",
            "values": {
                "user_id": 123456
            }
        }],
    "attachments": [{
            "type": "text/plain",
            "name": "myfile.txt",
            "content": "ZXhhbXBsZSBmaWxl"
        }],
    "images": [{
            "type": "image/png",
            "name": "IMAGECID",
            "content": "ZXhhbXBsZSBmaWxl"
        }]
};
var async = false;
var ip_pool = "Main Pool";
var send_at = "example send_at";
mandrill_client.messages.send({"message": message, "async": async, "ip_pool": ip_pool, "send_at": send_at}, function(result) {
    console.log(result);
    /*
    [{
            "email": "recipient.email@example.com",
            "status": "sent",
            "reject_reason": "hard-bounce",
            "_id": "abc123abc123abc123abc123abc123"
        }]
    */
}, function(e) {
    // Mandrill returns the error as an object with name and message keys
    console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
    // A mandrill error occurred: Unknown_Subaccount - No subaccount exists with the id 'customer-123'
});

正如此处指出的:

https://mandrillapp.com/api/docs/messages.nodejs.html

希望对您有所帮助:)

找到了一个更清晰易用的名为“sendgrid”的服务。 关于如何记录/集成/运行 的节点 Js 示例比 mailchimp/mandrill 好得多。