Skip to content

Smtp failed to send an attachment file #26352

Description

@Dzof12

Failed to send an email notification with attachment using smtp. hass.io version 0.98.1
Script

send_email_attachement:
     alias: "Send email snapshot"
     sequence:
       - service: notify.email
         data:
           message: "hello world"
           title: "hello"
           data:
             images: /tmp/snapshot.jpg

Log error details:

Log Details (ERROR)

Sun Sep 01 2019 23:51:42 GMT+0200 (heure d’été d’Europe centrale)

Error executing script script.send_email_attachement. Unknown error for call_service at pos 1: 

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 209, in async_turn_on
    await self.script.async_run(kwargs.get(ATTR_VARIABLES), context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 151, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 235, in _handle_action
    await self._actions[_determine_action(action)](action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 318, in _async_call_service
    context=context,
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 98, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context
  File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/notify/__init__.py", line 120, in async_notify_message
    await notify_service.async_send_message(**kwargs)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 178, in send_message
    msg = _build_multipart_msg(message, images=data.get(ATTR_IMAGES, []))
  File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 234, in _build_multipart_msg
    with open(atch_name, "rb") as attachment_file:
IsADirectoryError: [Errno 21] Is a directory: '/'

Metadata

Metadata

Assignees

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions