Closed jonas-jaderberg closed 1 year ago
Thanks for the report. We'll try to take a look at this over the next couple of weeks, and, presuming it is a bug we can fix, will make available in the next patch release
Thank you! For your information, this issue is preventing my client from deploying their new site. So let me know if you need more information or if there is anything I can test or verify.
I've not been able to replicate this issue with testing locally using smtp4dev
.
Could I ask please if you could verify initially that you can send emails from your project with attachments, outside of Forms?
If you add this controller to your project, update the path to a file that you want to attach to the email (ideally an example of one of the file uploads you are looking to send with Forms), and browse to /umbraco/surface/EmailTest/SendEmail
, you should find an email is sent with an attachment.
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Mail;
using Umbraco.Cms.Core.Models.Email;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Common.Security;
using Umbraco.Cms.Web.Website.Controllers;
namespace Umbraco.Forms.Testsite.Controllers
{
public class TestEmailController : SurfaceController
{
private readonly IMemberManager _memberManager;
private readonly IMemberSignInManager _memberSignInManager;
private readonly IEmailSender _emailSender;
public TestEmailController(
IUmbracoContextAccessor umbracoContextAccessor,
IUmbracoDatabaseFactory databaseFactory,
ServiceContext services,
AppCaches appCaches,
IProfilingLogger profilingLogger,
IPublishedUrlProvider publishedUrlProvider,
IMemberManager memberManager,
IMemberSignInManager memberSignInManager,
IEmailSender emailSender)
: base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider)
{
_memberManager = memberManager;
_memberSignInManager = memberSignInManager;
_emailSender = emailSender;
}
[HttpGet]
public async Task<IActionResult> SendEmail()
{
const string FilePath = "c:\\temp\\test.jpg";
using (var stream = new FileStream(FilePath, FileMode.Open))
{
var attachments = new List<EmailMessageAttachment>
{
new EmailMessageAttachment(stream, "test.jpg")
};
var message = new EmailMessage(
"from@test.com",
new[] { "to@test.com" },
null,
null,
null,
"Subject",
"Message",
false,
attachments);
await _emailSender.SendAsync(message, emailType: "Test");
return Content("Email sent.");
}
}
}
}
If that works, then there would seem to be something going on with Forms that we'll need to dig into further.
If it doesn't, then it suggests something upstream causing the issue - either in the CMS, or at the SMTP provider you are using.
I copied the code and did some smal adjustments. I run it and I can send and receive the email including the attachment. So there is no problem with the CMS and SMTP provider. I have tested with two different email providers / servers but same problem so the problem cannot be there. I do use uSkinned as well but I cannot that should interfere, especially when the test above works.
Thanks for checking this. As a next step. could you share your form definition please? Maybe if I try to import it I'll see something that differs from my local test.
If you browse in the Forms tree, right-click and you'll see an Export... option. If you use that you'll get a JSON file. If you prefer not to share publicly please feel free to email it to me at abl AT umbraco DOT dk. Thanks.
I have tested with just an "empty" form as well, same problem. It includes just a dataConsent and a File Upload. Here is an export of it. Just changed my email address in it. form-b3a46f19-7a52-4b49-ba93-b09a8ebbfd22.json.txt
I have also tested with the "standard" Example-Template so it's not my template that is causing the problem. In the backoffice I can see that the file is uploaded.
OK, that seems to work for me. Struggling to see at the moment what might be different to cause the problem in your case.
How feasible would it be for you to send me a copy of your project so I could run it locally (and then debug into the forms code for sending the email to see where it is failing)? If it's possible to send a zip, database backup and back-office login to the address above, I can try to figure it out via that route.
Or... if it's a Cloud project, maybe it's one you can invite me to so I can clone it locally.
I tested on one more site which I have, a much smaler one, same problem. It's using Umbraco 10.3.2 and Umbraco Forms 10.2.0+cf62a8f. I will send you an email on how to share the code.
I've found the issue here following testing with your project, so thanks for lending that. I've found an issue retrieving the attachments when a non-default media file system is being used. We'll get that fixed and released in the next patch updates.
Great! Is there any date when 11.0.2 will be released?
No, not yet I'm afraid. Unfortunately this missed the latest patch release which went out on Tuesday. But once we've got my proposed fix reviewed and tested we'll look to get the next round of releases prepared.
I have upgraded from Umbraco 8 with Umbraco Forms to Umbraco 11 with Umbraco Forms 11. Some of my forms included FileUpload field, in Umbraco 8 the files uploaded where included as attachemnts in the workflow send email. But in version 11 the attachment does not appear in the received email. The email razor template works. In the Send email workflow the Attachemnts switch is on. There is no error in the Logs. If I look at the submitted form in the backoffice via Form/Entries I can see the uploaded File. So the uploaded file is not attached to the email.
I have been in contact with Umbraco Forms support and they see the same behaviour.
I think the Attachemnts switch (or logic behind) in the workflow settings of "Send email with template (Razor)" workflow is currently not working in V11..