Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nick 97 posts 514 karma points
    Jun 03, 2024 @ 10:46
    Nick
    0

    Umbraco Forms Error: MailKit.Net.Smtp.SmtpCommandException

    Hi,

    I have a strange issue with Umbraco Forms on my umbraco 11.4.1 Cloud instance, my form has been working fine, but all of a sudden the workflow audit shows a fail see image below there have been no changes deployed and comes with the following error code:

    enter image description here

        MailKit.Net.Smtp.SmtpCommandException: Requested action not taken: mailbox unavailable
    Sender address is not allowed.
       at MailKit.Net.Smtp.SmtpClient.OnSenderNotAccepted(MimeMessage message, MailboxAddress mailbox, SmtpResponse response)
       at MailKit.Net.Smtp.SmtpClient.ParseMailFromResponse(MimeMessage message, MailboxAddress mailbox, SmtpResponse response)
       at MailKit.Net.Smtp.SmtpClient.MailFromAsync(FormatOptions options, MimeMessage message, MailboxAddress mailbox, SmtpExtensions extensions, Int64 size, Boolean pipeline, CancellationToken cancellationToken)
       at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, CancellationToken cancellationToken, ITransferProgress progress)
       at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, CancellationToken cancellationToken, ITransferProgress progress)
       at Umbraco.Cms.Infrastructure.Mail.EmailSender.SendAsyncInternal(EmailMessage message, String emailType, Boolean enableNotification)
       at Umbraco.Cms.Infrastructure.Mail.EmailSender.SendAsync(EmailMessage message, String emailType)
       at Umbraco.Forms.Core.Services.WorkflowEmailService.SendEmailAsync(SendEmailArgs args)
       at Umbraco.Forms.Core.Providers.WorkflowTypes.SendRazorEmail.Execute(WorkflowExecutionContext context)
    

    Any help with this error would be much appreciated as ever,

    Many thanks

    Nick

  • Nick 97 posts 514 karma points
    Jun 05, 2024 @ 16:00
    Nick
    0

    NUDGE

    Just ondered if anyone has any thoughts on this issue?

  • Kevin Meilander 82 posts 408 karma points c-trib
    Jun 06, 2024 @ 03:07
    Kevin Meilander
    0

    What SMTP service are you using? Does that have any more details for why it’s failing?

  • Nick 97 posts 514 karma points
    Jun 06, 2024 @ 08:40
    Nick
    0

    Hi Kevin,

    Thanks for getting back to me on this, these are the SMTP settings within the Appsettings.json file:

    "Smtp": {
              "From": "[email protected]",
              "Host": "smtp.ionos.co.uk",
              "Port": 587,
              "DeliveryMethod": "Network",
              "SecureSocketOptions": "StartTls",
              "Username": "*************",
              "Password": "*************"
            }
    

    Username and password obviously commented out, double checked the username and password still no joy. The only error message receive is the one above, I've also tried with different recipient email address where I know the mailbox is available but still the same error message :-(

  • Nick 97 posts 514 karma points
    Jun 06, 2024 @ 11:20
    Nick
    0

    UPDATE

    I've beenn messing around with the Umbraco Forms workflow, and think I might of stumbled across something when choosing a workflow for the form I am presented with the following options:

    enter image description here

    My current workflow which is failing uses a Razor template to send emails, if I just select the Send Email option and test everything works fine, so in conclusion looks like the Razor template is an issue I've tried the stand alone razor template in addition to my modified version and they both fail.

    It's a short-term fix for now using withotu Razor but ideally I would liek to use the template for the emails, here is the code below if anybody can see any issues:

    @using Microsoft.AspNetCore.Html
    @using Umbraco.Forms.Core.Extensions
    @using Umbraco.Cms.Web.Common.PublishedModels;
    @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Forms.Core.Models.FormsHtmlModel>
    @{
        //This is an example email template where you can use Razor Views to send HTML emails
    
        //You can use Umbraco.Content & Umbraco.Media etc to use Images & content from your site
        //directly in your email templates too
    
        //Strongly Typed
        //@Model.GetValue("aliasFormField")
        //@foreach (var color in Model.GetValues("checkboxField")){}
    
    
        //Images need to be absolute - so fetching domain to prefix with images
        var siteDomain = Context.Request.Scheme + "://" + Context.Request.Host;
        var assetUrl = siteDomain + "/assets/images";
    }
    
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <style type="text/css">
    
            /* CLIENT-SPECIFIC STYLES */
            body, table, td, a {
                -webkit-text-size-adjust: 100%;
                -ms-text-size-adjust: 100%;
            }
    
            table, td {
                mso-table-lspace: 0pt;
                mso-table-rspace: 0pt;
            }
    
            img {
                -ms-interpolation-mode: bicubic;
            }
    
            /* RESET STYLES */
            img {
                border: 0;
                height: auto;
                line-height: 100%;
                outline: none;
                text-decoration: none;
            }
    
            table {
                border-collapse: collapse !important;
            }
    
            body {
                height: 100% !important;
                margin: 0 !important;
                padding: 0 !important;
                width: 100% !important;
            }
    
            /* iOS BLUE LINKS */
            a[x-apple-data-detectors] {
                color: inherit !important;
                text-decoration: none !important;
                font-size: inherit !important;
                font-family: inherit !important;
                font-weight: inherit !important;
                line-height: inherit !important;
            }
    
            /* MOBILE STYLES */
            @@media screen and (max-width:600px) {
                h1 {
                    font-size: 32px !important;
                    line-height: 32px !important;
                }
            }
    
            /* ANDROID CENTER FIX */
            div[style*="margin: 16px 0;"] {
                margin: 0 !important;
            }
        </style>
    </head>
    <body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;">
        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-bottom: 40px;">
            <!-- LOGO -->
            <tr>
                <td bgcolor="#00afee" align="center" style="background:linear-gradient(90deg, #00afee 25%, #0b85b1 100%)">
                    <!--[if (gte mso 9)|(IE)]>
                        <table align="center" border="0" cellspacing="0" cellpadding="0" width="600">
                        <tr>
                        <td align="center" valign="top" width="600">
                    <![endif]-->
                    <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                        <tr>
                            <td align="center" valign="top" style="padding: 40px 10px 40px 10px;">
                                <a href="https://www.saietta.com" target="_blank">
                                    <img alt="Saietta" src="@assetUrl/logo-white.png" width="220" style="display: block; width: 220px; max-width: 220px; min-width: 220px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; font-size: 24px;" border="0">
                                </a>
                            </td>
                        </tr>
                    </table>
                    <!--[if (gte mso 9)|(IE)]>
                        </td>
                        </tr>
                        </table>
                    <![endif]-->
                </td>
            </tr>
    
            <!-- HERO -->
            <tr>
                <td bgcolor="#00afee" align="center" style="padding: 0px 10px 0px 10px;background:linear-gradient(90deg, #00afee 25%, #0b85b1 100%)">
                    <!--[if (gte mso 9)|(IE)]>
                        <table align="center" border="0" cellspacing="0" cellpadding="0" width="600">
                        <tr>
                        <td align="center" valign="top" width="600">
                    <![endif]-->
                    <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                        <tr>
                            <td bgcolor="#ffffff" align="center" valign="top" style="padding: 40px 20px 20px 20px; color: #000000; font-family: Helvetica, Arial, sans-serif; font-size: 36px; font-weight: 900; line-height: 48px;">
                                <h1 style="font-size: 32px; font-weight: 900; margin: 0;">Vacancy Application</h1>
                            </td>
                        </tr>
                    </table>
                    <!--[if (gte mso 9)|(IE)]>
                        </td>
                        </tr>
                        </table>
                    <![endif]-->
                </td>
            </tr>
    
            <!-- COPY BLOCK -->
            <tr>
                <td bgcolor="#F3F3F5" align="center" style="padding: 0px 10px 0px 10px;">
                    <!--[if (gte mso 9)|(IE)]>
                        <table align="center" border="0" cellspacing="0" cellpadding="0" width="600">
                        <tr>
                        <td align="center" valign="top" width="600">
                    <![endif]-->
                    <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
    
                        <!-- COPY -->
                        <tr>
                            <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #303033; font-family: Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 1.6em;">
                                Your application has been received, and we want to assure you that our hiring team is carefully reviewing each application we receive. We understand the importance of this opportunity to you, and we are committed to conducting a thorough evaluation of your qualifications.
                            </td>
                        </tr>
    
                        <!-- FORM FIELDS HEADING -->
                        <tr>
                            <td bgcolor="#ffffff" align="left" style="padding: 40px 30px 0px 30px; color: #000000; font-family: Helvetica, Arial, sans-serif; line-height: 25px;">
                                <h2 style="font-size: 24px; font-weight: 700; margin: 0;">Form Results</h2>
                            </td>
                        </tr>
    
                        <!-- FORM FIELDS -->
                        <tr>
                            <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #303033; font-family: Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
    
                                @{
                                    string[] ignoreFields = new string[]
                                    {
                                        "FieldType.Recaptcha2.cshtml",
                                        "FieldType.Recaptcha3.cshtml",
                                        "FieldType.RichText.cshtml",
                                        "FieldType.Text.cshtml"
                                    };
                                }
    
                                @foreach (var field in Model.Fields.Where(x => ignoreFields.Contains(x.FieldType) == false))
                                {
                                    <h4 style="font-weight: 700; margin: 0; color: #000000;">@field.Name</h4>
    
                                    <p style="margin-top: 0;">
                                        @switch (field.FieldType)
                                        {
                                            case "FieldType.FileUpload.cshtml":
                                                var uploadCount = 0;
                                                foreach (var fileUploadValue in field.GetValues())
                                                {
                                                    if (fileUploadValue != null && !string.IsNullOrEmpty(fileUploadValue.ToString()))
                                                    {
                                                        uploadCount++;
                                                    }
                                                }
    
                                                if (uploadCount > 0)
                                                {
                                                    <span>@uploadCount file@(uploadCount == 1 ? string.Empty : "s") uploaded</span>
                                                }
    
                                                break;
    
                                            case "FieldType.DatePicker.cshtml":
                                                var datePickerValue = field.GetValue();
                                                if (datePickerValue != null && !string.IsNullOrEmpty(datePickerValue.ToString()))
                                                {
                                                    DateTime dt;
                                                    var dateValid = DateTime.TryParse(datePickerValue != null ? datePickerValue.ToString() : string.Empty, out dt);
                                                    var dateStr = dateValid ? dt.ToString("f") : "";
                                                    @dateStr
                                                }
                                                break;
    
                                            default:
                                                var values = field.GetValues();
                                                if (values != null)
                                                {
                                                    foreach (var value in values)
                                                    {
                                                        if (value != null)
                                                        {
                                                            @(value is string ? value.ToString().ApplyPrevalueCaptions(field.Id, Model.PrevalueMaps) : value)<br />
                                                        }
                                                    }
                                                }
                                                break;
                                        }
                                    </p>
                                }
    
                            </td>
                        </tr>
    
                        <!-- FOOTER COPY -->
    
                            <tr>
                                <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #303033; font-family: Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 1.6em;">
                                &copy; Exedy Clutch Europe Limited 2024 All Rights Reserved
                                </td>
                            </tr>
    
                    </table>
                    <!--[if (gte mso 9)|(IE)]>
                        </td>
                        </tr>
                        </table>
                    <![endif]-->
                </td>
            </tr>
    
        </table>
    </body>
    </html>
    
  • Nick 97 posts 514 karma points
    Jun 13, 2024 @ 14:40
    Nick
    0

    UPDATE

    Managed to get this working now, it seems the from address also needs to be the same as the smtp user email, doesn't seem that should work but it does.

    Thanks for all your help

Please Sign in or register to post replies

Write your reply to:

Draft