question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
overbyrncommented, Dec 23, 2020

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)

0reactions
nicoh88commented, 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. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python3 SMTP ValueError: server_hostname cannot be an ...
_session, ValueError: server_hostname cannot be an empty string or start with a leading dot. I am using python 3.7 on Mac and cannot...
Read more >
server_hostname cannot be an empty string or start with a ...
ValueError : server_hostname cannot be an empty string or start with a leading dot. 1. 解决办法. import smtplib smtplib.SMTP_SSL(host= ...
Read more >
Automate 11 - Hostname cannot be empty. - Fortra Community
Hi All,. I am getting the following error whenever automate tries to send email notification. System.ArgumentException: Hostname cannot be empty.
Read more >
Configuring an SMTP mail server to send notifications
From the top navigation bar select Administration > System. · Select Mail > Outgoing Mail to open the SMTP Mail Server page.
Read more >
Postfix Configuration Parameters
The numerical Postfix SMTP server response code for an access(5) map "defer" ... $helo_name: The hostname given in HELO or EHLO command or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found