mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-05-06 08:49:25 -05:00
adding email nodes
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
|
||||
using MailKit.Net.Smtp;
|
||||
using MimeKit;
|
||||
|
||||
namespace FileFlows.Communication
|
||||
{
|
||||
public class SendEmail:Node
|
||||
{
|
||||
public override int Inputs => 1;
|
||||
public override int Outputs => 1;
|
||||
public override string Icon => "fas fa-envelope";
|
||||
|
||||
public override FlowElementType Type => FlowElementType.Process;
|
||||
|
||||
[StringArray(1)]
|
||||
public string[] Recipients { get; set; }
|
||||
|
||||
[TextVariable(2)]
|
||||
public string Subject { get; set; }
|
||||
|
||||
[TextArea(3)]
|
||||
public string Body { get; set; }
|
||||
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
var settings = args.GetPluginSettings<PluginSettings>();
|
||||
|
||||
if (string.IsNullOrEmpty(settings?.SmtpServer))
|
||||
{
|
||||
args.Logger?.ELog("No SMTP Server configured, configure this under the 'Plugins > Email Nodes > Edit' page.");
|
||||
return -1;
|
||||
}
|
||||
string body = this.Body ?? string.Empty;
|
||||
string sender = settings.Sender ?? "fileflows@" + Environment.MachineName;
|
||||
string subject = args.ReplaceVariables(this.Subject ?? String.Empty)?.EmptyAsNull() ?? "Email from FileFlows"; ;
|
||||
|
||||
var message = new MimeMessage();
|
||||
message.From.Add(new MailboxAddress(sender, sender));
|
||||
foreach (var recipient in Recipients)
|
||||
message.To.Add(new MailboxAddress(recipient, recipient));
|
||||
message.Subject = subject;
|
||||
message.Body = new TextPart("plain")
|
||||
{
|
||||
Text = body
|
||||
};
|
||||
|
||||
using(var client = new SmtpClient())
|
||||
{
|
||||
client.Connect(settings.SmtpServer, settings.SmtpPort);
|
||||
|
||||
if (string.IsNullOrEmpty(settings.SmtpUsername) == false)
|
||||
{
|
||||
args.Logger?.ILog("Sending using credientials");
|
||||
client.AuthenticationMechanisms.Remove("XOAUTH2");
|
||||
client.Authenticate(settings.SmtpUsername, settings.SmtpPassword);
|
||||
}
|
||||
client.Send(message);
|
||||
client.Disconnect(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//MailMessage message = new MailMessage();
|
||||
//message.From = new MailAddress(sender);
|
||||
//foreach (var recipient in Recipients)
|
||||
// message.To.Add(recipient);
|
||||
//message.Subject = subject;
|
||||
//message.Body = args.ReplaceVariables(body);
|
||||
|
||||
|
||||
|
||||
//SmtpClient smtp = new SmtpClient();
|
||||
//smtp.Port = settings.SmtpPort;
|
||||
//smtp.Host = settings.SmtpServer;
|
||||
//if (string.IsNullOrEmpty(settings.SmtpUsername) == false)
|
||||
//{
|
||||
// args.Logger?.ILog("Sending using credientials");
|
||||
// smtp.EnableSsl = true;
|
||||
// smtp.UseDefaultCredentials = false;
|
||||
// smtp.Credentials = new NetworkCredential(settings.SmtpUsername, settings.SmtpPassword);
|
||||
// //smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
//}
|
||||
//smtp.Send(message);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"Plugins": {
|
||||
"EmailNodes": {
|
||||
"Fields": {
|
||||
"SmtpServer": "SMTP Server",
|
||||
"SmtpServer-Help": "The address of the SMTP Server used to send emails",
|
||||
"SmtpPort": "SMTP Port",
|
||||
"SmtpPort-Help": "The port of the SMTP Server used to send emails, default 25",
|
||||
"SmtpUsername": "SMTP Username",
|
||||
"SmtpUsername-Help": "The username used to authenticate against the SMTP Server",
|
||||
"SmtpPassword": "SMTP Password",
|
||||
"SmtpPassword-Help": "The password used to authenticate against the SMTP Server"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Flow": {
|
||||
"Parts": {
|
||||
"SendEmail": {
|
||||
"Outputs": {
|
||||
"1": "Sent email to {Recipient}"
|
||||
},
|
||||
"Description": "Sends an email using the configured SMTP Server",
|
||||
"Fields": {
|
||||
"Recipients": "Recipients",
|
||||
"Recipients-Help": "A list of email addresses to send the message to",
|
||||
"Subject": "Subject",
|
||||
"Subject-Help": "The subject of the email being set",
|
||||
"Body": "Body",
|
||||
"Body-Help": "The content of the email message being sent. "
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace FileFlows.EmailNodes
|
||||
{
|
||||
internal static class ExtensionMethods
|
||||
{
|
||||
public static void AddOrUpdate(this Dictionary<string, object> dict, string key, object value) {
|
||||
if (dict.ContainsKey(key))
|
||||
dict[key] = value;
|
||||
else
|
||||
dict.Add(key, value);
|
||||
}
|
||||
public static string? EmptyAsNull(this string str)
|
||||
{
|
||||
return str == string.Empty ? null : str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
global using FileFlows.Plugin;
|
||||
global using FileFlows.EmailNodes;
|
||||
global using FileFlows.Plugin.Attributes;
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace FileFlows.EmailNodes
|
||||
{
|
||||
public class Plugin : IPlugin
|
||||
{
|
||||
public string Name => "Email Nodes";
|
||||
public string MinimumVersion => "0.3.1.378";
|
||||
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace FileFlows.EmailNodes
|
||||
{
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public class PluginSettings:IPluginSettings
|
||||
{
|
||||
[Required]
|
||||
[Text(1)]
|
||||
public string SmtpServer { get; set; }
|
||||
|
||||
[Range(1, 6555)]
|
||||
[NumberInt(1)]
|
||||
public int SmtpPort { get; set; }
|
||||
|
||||
[Text(2)]
|
||||
public string SmtpUsername { get; set; }
|
||||
|
||||
[Text(3)]
|
||||
public string SmtpPassword { get; set; }
|
||||
|
||||
[Text(4)]
|
||||
[Required]
|
||||
[System.ComponentModel.DataAnnotations.RegularExpression(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")]
|
||||
public string Sender { get; set; }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -54,4 +54,5 @@ Kbps
|
||||
AAC
|
||||
WAV
|
||||
OGG
|
||||
FLAC
|
||||
FLAC
|
||||
SMTP
|
||||
Binary file not shown.
@@ -1,99 +0,0 @@
|
||||
[
|
||||
{
|
||||
"Name": "Basic Nodes",
|
||||
"Version": "0.0.1.80",
|
||||
"MinimumVersion": "0.2.1.349",
|
||||
"Authors": "John Andrews",
|
||||
"Url": "https://fileflows.com/",
|
||||
"Description": "Basic nodes for FileFlows. This plugin contains basic and common nodes to process files. \r\nThis plugin is required for FileFlows to work.",
|
||||
"Package": "BasicNodes",
|
||||
"Elements": [
|
||||
"InputFile",
|
||||
"InputFolder",
|
||||
"CopyFile",
|
||||
"Delete",
|
||||
"DeleteSourceDirectory",
|
||||
"Executor",
|
||||
"MoveFile",
|
||||
"Renamer",
|
||||
"ReplaceOriginal",
|
||||
"Zip",
|
||||
"FileExists",
|
||||
"FileExtension",
|
||||
"FileSize",
|
||||
"Function",
|
||||
"GotoFlow",
|
||||
"Log",
|
||||
"PatternMatch",
|
||||
"PatternReplacer"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "Checksum Nodes",
|
||||
"Version": "0.0.1.80",
|
||||
"MinimumVersion": "",
|
||||
"Authors": "John Andrews",
|
||||
"Url": "https://fileflows.com/",
|
||||
"Description": "Nodes that provide the ability to run a checksum against a file.",
|
||||
"Package": "ChecksumNodes",
|
||||
"Elements": [
|
||||
"MD5",
|
||||
"SHA1",
|
||||
"SHA256",
|
||||
"SHA512"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "Collection Nodes",
|
||||
"Version": "0.0.1.80",
|
||||
"MinimumVersion": "0.2.0.310",
|
||||
"Authors": "John Andrews",
|
||||
"Url": "https://fileflows.com/",
|
||||
"Description": "Nodes that provide the ability to read and write from collections.\r\n\r\nAllows storing of data to database that persists between flow executions.",
|
||||
"Package": "CollectionNodes",
|
||||
"Elements": [
|
||||
"DataCollection"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "Meta Nodes",
|
||||
"Version": "0.0.1.80",
|
||||
"MinimumVersion": "",
|
||||
"Authors": "John Andrews",
|
||||
"Url": "https://fileflows.com/",
|
||||
"Description": "A plugin that contains Meta information nodes used to lookup meta information on files.\r\n\r\nContains nodes to lookup movie information from TheMovieDB, and music information from ID3 tags inside the file.",
|
||||
"Package": "MetaNodes",
|
||||
"Elements": [
|
||||
"MusicMeta",
|
||||
"MovieLookup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "Video Nodes",
|
||||
"Version": "0.0.1.80",
|
||||
"MinimumVersion": "",
|
||||
"Authors": "John Andrews",
|
||||
"Url": "https://fileflows.com/",
|
||||
"Description": "Nodes for processing video files. This plugin contains nodes to convert video files to different formats. Node to parse the video information from a file.",
|
||||
"Package": "VideoNodes",
|
||||
"Elements": [
|
||||
"VideoFile",
|
||||
"AudioAdjustVolume",
|
||||
"AudioNormalization",
|
||||
"AudioTrackReorder",
|
||||
"AudioTrackSetLanguage",
|
||||
"ComskipChapters",
|
||||
"ComskipRemoveAds",
|
||||
"FFMPEG",
|
||||
"RemuxToMKV",
|
||||
"RemuxToMP4",
|
||||
"SubtitleExtractor",
|
||||
"SubtitleRemover",
|
||||
"Video_H265_AC3",
|
||||
"VideoEncode",
|
||||
"VideoScaler",
|
||||
"DetectBlackBars",
|
||||
"VideoCodec"
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user