Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "mgarcia"

Hi Alper!

"check that _smtpEmailSenderConfiguration.UserName has value"

Thats something Ive been trying to explain in this topic for a while, I already checked that values for Host and Tenant, it has the corresponding value for each account ( Host take his own credentials and Tenant also his own credentials) But when it comes to send the email it fails.

I think the problem is being occured by IEmailSenderConfiguration interface and the field DefaultFromAddress that is only a get and take the value from Host Account, it cannot be replace or changed.

I'll send you the credentials to the given email.

Hi!

The code is already doing that on Core Project -> MasterPagoCoreModule.cs

    public class Office365SmtpBuilder : IMailKitSmtpBuilder
    {
        private readonly ISmtpEmailSenderConfiguration _smtpEmailSenderConfiguration;

        public Office365SmtpBuilder(ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration)
        {
            _smtpEmailSenderConfiguration = smtpEmailSenderConfiguration;
        }

        public virtual SmtpClient Build()
        {
            var client = new SmtpClient();

            try
            {
                ConfigureClient(client);
                return client;
            }
            catch
            {
                client.Dispose();
                throw;
            }
        }

        protected virtual void ConfigureClient(SmtpClient client)
        {
            client.ServerCertificateValidationCallback = (s, c, h, e) => true;  //added this line

            client.Connect(
                _smtpEmailSenderConfiguration.Host,
                _smtpEmailSenderConfiguration.Port,
                _smtpEmailSenderConfiguration.EnableSsl
            );

            client.AuthenticationMechanisms.Remove("XOAUTH2");  //added this line
            var userName = _smtpEmailSenderConfiguration.UserName;
            if (!userName.IsNullOrEmpty())
            {
                client.Authenticate(
                    _smtpEmailSenderConfiguration.UserName,
                    _smtpEmailSenderConfiguration.Password
                );
            }
        }
    }

Each Time the method SendTestEmail() in SettingAppServiceBase class is invoke it creates the SMTP client with the corresponding credentials.

namespace DACOR.Masterpago.Configuration
{
    public abstract class SettingsAppServiceBase : MasterpagoAppServiceBase
    {
        private readonly IEmailSender _emailSender;

        protected SettingsAppServiceBase(
            IEmailSender emailSender)
        {
            _emailSender = emailSender;
        }

        #region Send Test Email

        public async Task SendTestEmail(SendTestEmailInput input)
        {
            try
            {
                await _emailSender.SendAsync(
                    input.EmailAddress,
                    L("TestEmail_Subject"),
                    L("TestEmail_Body")
                );
            }
            catch (System.Exception e)
            {

                throw e;
            }
        }

        #endregion
    }
}

added evidence both email accounts are working...

Hi alper,

"Why don't you try to test your SMTP settings with a 3rd party application."

Ive been writing that SMTP settings work fine, I have 2 SMTP accounts which I have tested on HOST and they WORK fine.

When I tried any of this account on tenants they FAIL.

I can show you if you really want to help me.

maliming or alper?

Hi,

What I meant is this... I got mails credentials lets call it "A" working on Production enviroment.

So I copied those credentials and used them on Development enviroment, on Host SMTP configuration, and they work fine.

But those credentials "A" doent work on tenant. Later I created a new mail account lets call it "B", I set it up on the Host in development and credentials "A" and "B" works as expected, but any of them works on Tenant. I follow up the code with debug and Tenant is getting the right values from DB, but it is something weird. Thats why I would like to show you guys.

Hi, Im been doing my best to explain my problem but it seems Im not being able to explain myself clearly.

I already debug all, test the creation of the SMTP client with the correspondent credentials for host and tenant, also I exchanged credentials BUT only Host is able to send emails.

On tenant it creates the client with his credentials but send fails. I would really appreciate if we can schedule a meeting on skype.

thx so much.

Hi!

Thats what it seems, but that same acc (username and password) on host is working right. But when use with tenant it fails. IEmailSender doesnt work fine when is call from tenant back office test email.

I event get others errors like this:

5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A000B81, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:C01C0000, 1.36674:0E000000, 1.61250:00000000, 1.45378:C51C0000, 1.44866:98010000, 16.55847:420F0000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F19880000F01F43050000, 20.50032:140F19887017F01F0A00C881, 0.35180:48050000, 255.23226:0A000000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A001181, 0.35250:80030400, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:44000000, 1.36674:32000000, 1.61250:00000000, 1.45378:49000000, 1.44866:02000000, 16.55847:B0000000, 17.43559:0000000010030000000000000000000000000000, 20.52176:140F1988000070200A001681, 20.50032:140F1988701710106B050000, 0.35180:0A001781, 255.23226:4800D13D, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:75050000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:7A050000, 0.38698:0F010480, 0.37692:0F010480, 0.44092:0D000100, 0.41232:0D000100, 0.60208:0D000100, 0.37136:0D000100, 0.34608:0D000100, 0.55056:0D000100, 0.42768:0D000100, 0.56112:0D000100, 0.52807:0D000100, 4.33016:DC040000, 7.40748:010000000000010B07000000, 7.57132:000000000000000007000000, 1.63016:32000000, 4.39640:DC040000, 8.45434:B8FE3C50A4E58E47AB4498236AB5842EC7000000, 5.10786:0000000031352E32302E323037332E3030303A4D4E32505231354D42333233323A33613961663663662D616634342D343135322D613733322D64326335306631626666663200201000000000, 255.1750:0A00F136, 255.31418:B1050000, 0.22753:0A002481, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A002581, 4.30158:DC040000 [Hostname=MN2PR15MB3232.namprd15.prod.outlook.com]

As I followed the code I can see how the SMTP client succesfully does the auth. Maybe I can show you and that could lead to an idea.

This same acc on host work fine, on tenant fails.

I would appreciate your help.

greetings,

Yeah, I was able to enter to github page. Right now Im following the idea described there.

So now I can show the SMTP setting tab on tenants configuration page and all records are being saved to BD succesfully as you can see on this picture:

But I keep raising an exception It show an url for help about mailkit but I havent been able to send emails. This account is being used on production server and it works. But on development and for tenancy it is not working.

I checked when it creates the SMTP client and it is using all tenants values as they were save. Maybe you can help me on skype so I can show you.

Can we talk by Skype?

Showing 1 to 10 of 29 entries