2sic / app-mobius-forms

Simple jQuery based 2sxc form - to use immediately or to modify as needed. Multi-language, simple, with Recaptcha

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SendMail doesn't work with SSL and doesn't handle errors

BeniFreitag opened this issue · comments

public bool send(
string emailTemplateFilename,
Dictionary<string,object> valuesWithMailLabels,
string MailFrom,
string MailTo,
string MailCC,
string MailReply,
List<ToSic.Sxc.Adam.IFile> files,
ToSic.SexyContent.IAppAndDataHelpers context)
{
// Check for attachments and add them to the mail
var attachments = files.Select(f =>
new System.Net.Mail.Attachment(
new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/") + f.Url, FileMode.Open), f.FullName)).ToList();
var mailEngine = TemplateInstance(emailTemplateFilename, context.App.Path);
var mailBody = mailEngine.Message(valuesWithMailLabels, context).ToString();
var mailSubj = mailEngine.Subject(valuesWithMailLabels, context);
// Send Mail
// uses the DNN command: http://www.dnnsoftware.com/dnn-api/html/886d0ac8-45e8-6472-455a-a7adced60ada.htm
Mail.SendMail(MailFrom, MailTo, MailCC, "", MailReply, MailPriority.Normal, mailSubj, MailFormat.Html, System.Text.Encoding.UTF8, mailBody, attachments, "", "", "", "", false);
return true;
}

  1. SendMail.Send() always returns true and doesn't handle STMP-Errors. Instead the result should check wheter DotNetNuke.Services.Mail.Mail.SendMail() returned an empty string (success) but otherwise return false (handle the error).
  2. It has smtpEnableSSL-parameter hardcoded to false (last parameter in DotNetNuke.Services.Mail.Mail.SendMail()). Instead this should be retrieved from DotNetNuke.Entities.Host.Host.EnableSMTPSSL.

great input - could you contribute? 😊

I believe this is fixed as the latest ones use a 2sxc IMailService. If not, feel free to re-open.