Update sendmail.js

This commit is contained in:
Namhyeon Go 2024-01-27 14:01:57 +09:00
parent 9cdfd205bf
commit 302b33d48b

View File

@ -6,21 +6,18 @@
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
var LIB = require("lib/std");
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Private APIs / Utility functions // Private APIs / Utility functions
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
exports.VERSIONINFO = "Sendmail Lib (sendmail.js) version 0.1"; var usePersitsMailSender = false;
exports.global = global; var useSSL = false;
exports.require = global.require;
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Send Mail Message // Send Mail Message
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
exports.sendmail = function(msg) { function sendmail(msg) {
var ok, MAIL; var ok, MAIL;
console.log("SENDMAIL: " + msg.To); console.log("SENDMAIL: " + msg.To);
@ -61,16 +58,16 @@ exports.sendmail = function(msg) {
} else { } else {
// Use CDO objects to send mail. Setup SMTP server details. // Use CDO objects to send mail. Setup SMTP server details.
var CONF = LIB.CreateObject("CDO.Configuration"); var CONF = CreateObject("CDO.Configuration");
CONF.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2; CONF.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = msg.MAILHOST; CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = msg.MAILHOST;
CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = msg.MAILPORT || 25; CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = msg.MAILPORT || 25;
CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0; CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0;
CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 0; CONF.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = (!useSSL ? 0 : 1);
CONF.Fields.Update(); CONF.Fields.Update();
// Create the email message // Create the email message
MAIL = LIB.CreateObject("CDO.Message"); MAIL = CreateObject("CDO.Message");
MAIL.Configuration = CONF; MAIL.Configuration = CONF;
CONF = null; CONF = null;
if (msg.Name) { if (msg.Name) {
@ -105,6 +102,8 @@ exports.sendmail = function(msg) {
return ok; return ok;
}; };
///////////////////////////////////////////////////////////////////////////////// exports.sendmail = sendmail;
return scope; exports.VERSIONINFO = "Sendmail Library (sendmail.js) version 0.1.1";
exports.global = global;
exports.require = global.require;