Jump to content

Recommended Posts

CBers
Posted

FOUND your issue!!!!!!

 

The from email has to be a plain email without the From name specified.  ahh thats the issue.   I can add a 'From Name' field if you like.

 

But just have email@address.here without the "Emby" and < and >

 

That was going to be my next test.

 

Will try that now and report back.

 

I like to use it like that, as I get so many emails from different services, it's nice to have a "friendly" name,

Anthony Musgrove
Posted
                mail.From.Add(new MailboxAddress(options.EmailFromName, options.EmailFrom));

 

Ive added it:) just compiling now

  • Like 1
CBers
Posted

OK, that worked running against port 465, but not 587.

2020-06-02 14:41:46.346 Info App: Connecting to smtpserver at smtp.gmail.com:465
2020-06-02 14:41:46.498 Info App: Authenticating to smtpserver using sender@gmail.com/<hidden>
2020-06-02 14:41:46.702 Info App: Sending email recipient@gmail.com with subject Emby: Emby: Test Notification
2020-06-02 14:41:48.003 Info App: Completed sending email recipient@gmail.com with subject Emby: Emby: Test Notification

When you hit the TEST NOTIFICATION button, there is no feedback on whether the email was sent, or not.

Anthony Musgrove
Posted

Too easy mate, I've added from name, just working on getting the feedback issue resolved now.

 

5ed65850cf1ca_Configurationemail.png

 

5ed6585dac89a_TestEmailSuccesswithName.p

  • Like 1
CBers
Posted

Just tested it using my VirginMedia email address and it works as well.
 

2020-06-02 14:46:08.700 Info App: Connecting to smtpserver at smtp.virginmedia.com:465
2020-06-02 14:46:09.389 Info App: Authenticating to smtpserver using sender@virginmedia.com/<hidden>
2020-06-02 14:46:09.451 Info App: Sending email recipient@gmail.com with subject Emby: Emby: Test Notification
2020-06-02 14:46:09.550 Info App: Completed sending email recipient@gmail.com with subject Emby: Emby: Test Notification
  • Like 1
CBers
Posted

Probably in the original code, but there is a spelling mistake in the description under the Email To field:

 

5ed65a67b3f37_Capture1145.jpg

 

"messaged" instead of "messages"

 

Not sure if you want to amend it.

  • Like 1
Anthony Musgrove
Posted

All fixed including the typo, feedback on testing (including error messages if any).  v4.0.0.4, ready to go.  I'll upload the DLL to the repo so you can test it if you like <3 

  • Like 1
Anthony Musgrove
Posted

 

Just tested it using my VirginMedia email address and it works as well.

 

2020-06-02 14:46:08.700 Info App: Connecting to smtpserver at smtp.virginmedia.com:465
2020-06-02 14:46:09.389 Info App: Authenticating to smtpserver using sender@virginmedia.com/<hidden>
2020-06-02 14:46:09.451 Info App: Sending email recipient@gmail.com with subject Emby: Emby: Test Notification
2020-06-02 14:46:09.550 Info App: Completed sending email recipient@gmail.com with subject Emby: Emby: Test Notification

Awesome! :) thank you so much for testing and helping.  

 

@@Luke wanted me to try to embed the source for MailKit and MimeKit into the package rather than including the two compiled DLLs, but it looks like it's going to be a massive task to embed the source with all the external dependencies.  I may just not be doing it the correct way, but any feedback is appreciated if anyone has any insight :)

  • Like 1
Posted

Important

We don't recommend that you use the SmtpClient class for new development because SmtpClient doesn't support many modern protocols. Use MailKit or other libraries instead. For more information, see SmtpClient shouldn't be used on GitHub.

Theres the issue. So you're more than 100% correct in saying that there is a problem with this plugin, however it is a very simple fix.

Im more then happy to rewrite the plugin using mailkit @@Luke if you wish. Ill do it when I get home from work

See here:

https://stackoverflow.com/questions/43517434/is-system-net-mail-smtpclient-obsolete-in-4-7

 

That comment only applies to using smtpclient in the mono runtime or xamarin. It's fully supported in .net core.

Anthony Musgrove
Posted

(just copying this here for input): I would probably suggest that we remove the System.Net.Mail.dll out of the Emby Core, and (eventually) include MailKit and MimeKit libraries in the core (because it is such an essential changeout), which would eliminate the need for any plugin to embed or include Mailkit or Mimekit dependencies. I wonder if that would be possible? Take for example the scenario where another plugin dev wants to send emails from their plugin -- System.Net.Mail.SmtpClient is now obsolete so no plugins should be using it, let's upgrade the core to natively support MailKit?

Anthony Musgrove
Posted

See here:

https://stackoverflow.com/questions/43517434/is-system-net-mail-smtpclient-obsolete-in-4-7

 

That comment only applies to using smtpclient in the mono runtime or xamarin. It's fully supported in .net core.

 

I see that mate yeah, but it still doesn't solve the issue around it not supporting a lot of the newer protocols, which is why Yahoo, Virginemail, etc fails 

Posted

(just copying this here for input): I would probably suggest that we remove the System.Net.Mail.dll out of the Emby Core, and (eventually) include MailKit and MimeKit libraries in the core (because it is such an essential changeout), which would eliminate the need for any plugin to embed or include Mailkit or Mimekit dependencies. I wonder if that would be possible? Take for example the scenario where another plugin dev wants to send emails from their plugin -- System.Net.Mail.SmtpClient is now obsolete so no plugins should be using it, let's upgrade the core to natively support MailKit?

As a principal if the core server isn't using it directly, then I would rather not embed it just from the standpoint of keeping things as lean as possible.

  • Like 1
Posted

I see that mate yeah, but it still doesn't solve the issue around it not supporting a lot of the newer protocols, which is why Yahoo, Virginemail, etc fails

 

Check out the comments about the using blocks. We could adjust the way smtpclient is used and then reevaluate where things stand after that.

 

But yes it will match the feature set of a dedicated library such as mailkit which is built for this purpose.

Anthony Musgrove
Posted

Do you mean something like this mate?

        public async Task SendNotification(UserNotification request, CancellationToken cancellationToken)
        {
            var options = GetOptions(request.User);

            MailMessage _message = new MailMessage(options.EmailFrom, options.EmailTo, "Emby: " + request.Name, string.Format("{0}\n\n{1}", request.Name, request.Description));

            SmtpClient _client = new SmtpClient(options.Server, options.Port);

            _client.DeliveryMethod = SmtpDeliveryMethod.Network;
            _client.UseDefaultCredentials = false;
            _client.Timeout = 20000;

            if(options.SSL)
                _client.EnableSsl = options.SSL;

            if(options.UseCredentials)
            {
                var pw = string.IsNullOrWhiteSpace(options.Password) ? _encryption.DecryptString(options.PwData) : options.Password;
                _client.Credentials = new NetworkCredential(options.Username, pw);
            }

            try
            {
                await _client.SendMailAsync(_message).ConfigureAwait(false);

                _logger.Info("Completed sending email {0} with subject {1}", options.EmailTo, _message.Subject);
            }
            catch (Exception ex)
            {
                _logger.Error("Error sending email: {0} ", ex);
            }
        }

Anthony Musgrove
Posted

[i cant seem to find any extensible options on the SmtpClient class though to implement or inject new protocols], so possibly it still won't support a lot of servers secure protocols 

CBers
Posted

@@Anthony.Musgrove

 

Not sure if this is a bug, but I have niw set up email notifications for my daughter's account, for when she has new content added, but when I send a test email via the plugin, it comes to me.

Anthony Musgrove
Posted

@@Anthony.Musgrove

 

Not sure if this is a bug, but I have niw set up email notifications for my daughter's account, for when she has new content added, but when I send a test email via the plugin, it comes to me.

 

Hey mate, I've just reviewed the code.  That's a strange one, because the 'test smtp' button code hasn't been changed at that point.  It's coded to send a test email to c.MediaBrowserUserId, which is changed every time a new user is selected from the dropdown box.  

 

Can you do me a favor though, do a test with you selected in the dropdown box, then do a test with your daughters account in the dropdown box, then send me the emby log so I can see if the userid's actually do change like they're meant to 

 

thank you :)

  • Like 1
Posted

Will these updates to the plugin be available from the emby plugin store?

 

Thanks

Anthony Musgrove
Posted

Will these updates to the plugin be available from the emby plugin store?

 

Thanks

Not at the moment mate, the official plugin is still under review as to which pathway it will take regarding the libraries for handling smtp.

 

Until its decided im more then happy to just leave the DLL on the github to manually install, provided @@Luke is okay with that plan. :)

Posted

Ok, I'm asking because I'm running emby on Synology, so it's not as easy to manually update.

 

Thanks for all your hard work though!

Anthony Musgrove
Posted

Your'e welcome mate. My plugin on the catalog also supports emailing using mailkit, search for Emby Scripter-X under the General section of the catalog. It may help you in the interim

Posted

Im using the docker container for embybeta and I suspect permissions etc stop me replacing this dll.

Im happy to wait until it is in the official release. 

rbjtech
Posted (edited)

Just some feedback @@Anthony.Musgrove - the plugin (4.0.0.4) is working for me over TCP 465 (SMTPS), previously I had to use TCP 587 (MSA) - Great Stuff.

 

I get the warning doing the test notification - but I'm receiving the email fine over SSL so many thanks for the core improvements !

 

edit ..

 

Also just read in the scripterX thread that you are a frontline healthcare worker - Given the state of the world at the moment, my first call of thanks is for that.  You guys are amazing.

 

How you cope with that and then find time to do all this amazing coding is inspirational .. :)

Edited by rbjtech

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...