#21103: Missing ReplyTo field & parameter == No Sending Emails.

Merge branch '1.x' of https://git01.codeplex.com/forks/abhishekluv/oproject into PR

Conflicts:
	src/Orchard.Web/Modules/Orchard.Email/Services/SmtpMessageChannel.cs

Work Item: 21103
This commit is contained in:
Sipke Schoorstra
2015-02-27 23:33:18 +01:00
7 changed files with 57 additions and 10 deletions

View File

@@ -11,7 +11,7 @@
</div>
<div class="help-item">
<h2 class="gallery">@T("Get more goodies")</h2>
<p>@T("Change the way your site works and looks with <a href=\"{0}\">themes</a> and <a href=\"{1}\">modules</a>. Theres plenty to choose from in the <a href=\"http://orchardproject.net/gallery\">Orchard Gallery</a>. Were always adding things, so be sure to check back often to see whats new.",
<p>@T("Change the way your site works and looks with <a href=\"{0}\">themes</a> and <a href=\"{1}\">modules</a>. Theres plenty to choose from in the <a href=\"http://gallery.orchardproject.net/\">Orchard Gallery</a>. Were always adding things, so be sure to check back often to see whats new.",
Url.Action("Themes", "Gallery", new { area = "Orchard.Packaging" }),
Url.Action("Modules", "Gallery", new { area = "Orchard.Packaging" }))
</p>

View File

@@ -55,12 +55,16 @@ namespace Orchard.Email.Activities {
var subject = activityContext.GetState<string>("Subject");
var recipients = activityContext.GetState<string>("Recipients");
var replyTo = activityContext.GetState<string>("ReplyTo");
var bcc = activityContext.GetState<string>("Bcc");
var cc = activityContext.GetState<string>("CC");
var parameters = new Dictionary<string, object> {
{"Subject", subject},
{"Body", body},
{"Recipients", recipients},
{"ReplyTo", replyTo}
{"ReplyTo", replyTo},
{"Bcc", bcc},
{"CC", cc}
};
var queued = activityContext.GetState<bool>("Queued");

View File

@@ -18,7 +18,7 @@ namespace Orchard.Email.Controllers {
public Localizer T { get; set; }
public ActionResult TestMailSettings(string to, string subject, string body) {
public ActionResult TestMailSettings(string to, string subject, string body, string replyTo, string bcc, string cc) {
ILogger logger = null;
try {
var fakeLogger = new FakeLogger();
@@ -30,7 +30,10 @@ namespace Orchard.Email.Controllers {
_smtpChannel.Process(new Dictionary<string, object> {
{"Recipients", to},
{"Subject", subject},
{"Body", body}
{"Body", body},
{"ReplyTo",replyTo},
{"Bcc", bcc},
{"CC",cc}
});
if (!string.IsNullOrEmpty(fakeLogger.Message)) {
return Json(new { error = fakeLogger.Message });

View File

@@ -36,12 +36,24 @@ namespace Orchard.Email.Forms {
Title: T("Email Addresses"),
Description: T("Specify a comma-separated list of recipient email addresses. To include a display name, use the following format: John Doe &lt;john.doe@outlook.com&gt;"),
Classes: new[] {"large", "text", "tokenized"}),
_Bcc: New.TextBox(
Id: "bcc",
Name: "Bcc",
Title: T("Bcc"),
Description: T("Specify a comma-separated list of email addresses for a blind carbon copy"),
Classes: new[]{"large","text","tokenized"}),
_CC: New.TextBox(
Id: "cc",
Name: "CC",
Title: T("CC"),
Description: T("Specify a comma-separated list of email addresses for a carbon copy"),
Classes: new[] { "large", "text", "tokenized" }),
_ReplyTo: New.Textbox(
Id: "reply-to",
Name: "ReplyTo",
Title: T("Reply To Address"),
Description: T("If necessary, specify an email address for replies."),
Classes: new [] {"medium", "text", "tokenized"}),
Classes: new [] {"large", "text", "tokenized"}),
_Subject: New.Textbox(
Id: "Subject", Name: "Subject",
Title: T("Subject"),
@@ -93,6 +105,7 @@ namespace Orchard.Email.Forms {
var recipients = context.ValueProvider.GetValue("Recipients").AttemptedValue;
var subject = context.ValueProvider.GetValue("Subject").AttemptedValue;
var body = context.ValueProvider.GetValue("Body").AttemptedValue;
if (String.IsNullOrWhiteSpace(recipients)) {
context.ModelState.AddModelError("Recipients", T("You must specify at least one recipient.").Text);

View File

@@ -4,5 +4,7 @@
public string Body { get; set; }
public string Recipients { get; set; }
public string ReplyTo { get; set; }
public string Bcc { get; set; }
public string CC { get; set; }
}
}

View File

@@ -45,10 +45,12 @@ namespace Orchard.Email.Services {
}
var emailMessage = new EmailMessage {
Body = parameters["Body"] as string,
Subject = parameters["Subject"] as string,
Recipients = parameters["Recipients"] as string,
ReplyTo = parameters.ContainsKey("ReplyTo") ? parameters["ReplyTo"] as string : null
Body = Read(parameters, "Body"),
Subject = Read(parameters, "Subject"),
Recipients = Read(parameters, "Recipients"),
ReplyTo = Read(parameters, "ReplyTo"),
Bcc = Read(parameters, "Bcc"),
CC = Read(parameters, "CC")
};
if (emailMessage.Recipients.Length == 0) {
@@ -113,5 +115,9 @@ namespace Orchard.Email.Services {
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
return smtpClient;
}
private string Read(IDictionary<string, object> dictionary, string key) {
return dictionary.ContainsKey(key) ? dictionary[key] as string : null;
}
}
}

View File

@@ -56,10 +56,22 @@
<label for="emailtestto">@T("To:")</label>
<input type="text" id="emailtestto" class="large text" />
</div>
<div>
<label for="emailtestbcc">@T("Bcc:")</label>
<input type="text" id="emailtestbcc" class="large text" />
</div>
<div>
<label for="emailtestcc">@T("CC:")</label>
<input type="text" id="emailtestcc" class="large text" />
</div>
<div>
<label for="emailtestsubject">@T("Subject:")</label>
<input type="text" id="emailtestsubject" class="large text" />
</div>
<div>
<label for="emailtestreplyto">@T("Reply To:")</label>
<input type="text" id="emailtestreplyto" class="large text" />
</div>
<div>
<textarea id="emailtestbody"></textarea>
</div>
@@ -76,12 +88,19 @@
info = $("#emailtestinfo"),
to = $("#emailtestto"),
subject = $("#emailtestsubject"),
body = $("#emailtestbody");
body = $("#emailtestbody"),
replyto = $("#emailtestreplyto"),
bcc = $("#emailtestbcc"),
cc = $("#emailtestcc");
$("#emailtestsend").click(function() {
$.post(url, {
to: to.val(),
subject: subject.val(),
body: body.val(),
replyto: replyto.val(),
bcc: bcc.val(),
cc: cc.val(),
__RequestVerificationToken: to.closest("form").find("input[name=__RequestVerificationToken]").val()
})
.fail(function(data) {