Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP - server_hostname cannot be an empty string or start with a leading dot. #227

Closed
nicoh88 opened this issue Nov 10, 2020 · 9 comments · Fixed by #277
Closed

SMTP - server_hostname cannot be an empty string or start with a leading dot. #227

nicoh88 opened this issue Nov 10, 2020 · 9 comments · Fixed by #277

Comments

@nicoh88
Copy link
Contributor

nicoh88 commented Nov 10, 2020

Hello Community,

I have a problem with the smtp notification settings.

Command: icloudpd --username=nico***@googlemail.com --password=*** --directory=/mnt/data/private/Bilder/2099-12-31\ iCloud/ --size=original --live-photo-size=original --auto-delete --folder-structure={:\%Y/\%m-\%B} --smtp-username blablabla@gmx.de --smtp-password o9*** --smtp-host mail.gmx.net --smtp-port 587 --notification-email nico***@gmail.com

Error:

Keyring config file contains incorrect values.
Config file: /root/.local/share/python_keyring/keyringrc.cfg
2020-11-10 21:30:35 DEBUG    Authenticating...
2020-11-10 21:30:37 INFO     Sending 'two-step expired' notification via email...
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/icloudpd/base.py", line 260, in main
    client_id=os.environ.get("CLIENT_ID"),
  File "/usr/local/lib/python3.7/dist-packages/icloudpd/authentication.py", line 44, in authenticate
    "Two-step/two-factor authentication is required!"
icloudpd.authentication.TwoStepAuthRequiredError: Two-step/two-factor authentication is required!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/icloudpd", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/icloudpd/base.py", line 272, in main
    notification_email,
  File "/usr/local/lib/python3.7/dist-packages/icloudpd/email_notifications.py", line 22, in send_2sa_notification
    smtp.starttls()
  File "/usr/lib/python3.7/smtplib.py", line 771, in starttls
    server_hostname=self._host)
  File "/usr/lib/python3.7/ssl.py", line 412, in wrap_socket
    session=session
  File "/usr/lib/python3.7/ssl.py", line 846, in _create
    owner=self, session=self._session,
ValueError: server_hostname cannot be an empty string or start with a leading dot.

But why? Can someone help me?

icloudpd --version
icloudpd, version 1.7.0

Installed over pip install icloudpd

Without the smtp options, works and downloading my photos, after two-factor authentication.

I cannot currently reproduce the problem because the two-factor authentication was successful. It will not occur again until two factor authentication is required again.

Cheers Nico

@menkej
Copy link
Collaborator

menkej commented Nov 12, 2020

Hi Nico,
I have not seen this issue yet, but I have not been using email-notification. Can you reproduce this behaviour?

Are you always seeing Keyring config file contains incorrect values.? Did you check /root/.local/share/python_keyring/keyringrc.cfg?

I'll try to reproduce myself tonight.

cheers
Jörg

@nicoh88
Copy link
Contributor Author

nicoh88 commented Nov 12, 2020

Hi Jörg,

thanks for your reply. Nope, I can not reproduce.
After delete /root/.local/share/python_keyring/keyringrc.cfg nothing changes.

Can I force a logout / reauthentication?

I'm curious what you find out.

Cheers,
Nico

@rsauget
Copy link

rsauget commented Dec 20, 2020

I don't have the keyring error, but I do have the smtp error as well when enabling notifications.

@overbyrn
Copy link

The error "server_hostname cannot be an empty string or start with a leading dot" seems to relate to a python bug with smtplib - https://bugs.python.org/issue36094

I was able to fix it by changing SMTP client session object creation in email_notifications.py from

smtp = smtplib.SMTP()

to

smtp = smtplib.SMTP(smtp_host, smtp_port)

@nicoh88
Copy link
Contributor Author

nicoh88 commented Jan 3, 2021

@AndreyNikiforov Can you fix this?

@menkej
Copy link
Collaborator

menkej commented Jan 3, 2021

Hi @nicoh88, does @overbyrn 's fix work for you? Then I'll include it in the next release.

@nicoh88
Copy link
Contributor Author

nicoh88 commented Jan 3, 2021

Can I do force a logout / reauthentication?

Only then, can i test it.

@menkej
Copy link
Collaborator

menkej commented Jan 4, 2021

@nicoh88 try to (re-) move ~/.pyicloud directory (or the directory you use for storing the auth cookies with --cookie-directory)

@nicoh88
Copy link
Contributor Author

nicoh88 commented Jan 4, 2021

@nicoh88 try to (re-) move ~/.pyicloud directory (or the directory you use for storing the auth cookies with --cookie-directory)

Works! You can merge the PR. 👍

menkej added a commit to menkej/icloud_photos_downloader that referenced this issue Jan 4, 2021
@menkej menkej mentioned this issue Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants