%Based upon https://github.com/benedictdudel/pandoc-letter-din5008
\documentclass[
    foldmarks=BTm,       % show foldmarks top, middle, bottom
    foldmarks=false,     % don't print foldmarks    
    fromalign=left,      % letter head on the right
    fromphone=true,      % show phone number
    fromemail=true,      % show email
    fromlogo=false,      % don't show logo in letter head
    version=last         % latest version of KOMA letter
    pagenumber=botright  % show pagenumbers on bottom right
]{scrlttr2}

\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
$if(title-meta)$
  pdftitle={$title-meta$},
$endif$
$if(author-meta)$
  pdfauthor={$author-meta$},
$endif$
$if(lang)$
  pdflang={$lang$},
$endif$
$if(subject)$
  pdfsubject={$subject$},
$endif$
$if(keywords)$
  pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
$endif$
}
\usepackage{url}

\usepackage{iftex}

%\usepackage[ngerman]{babel}
$if(lang)$
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{$babel-lang$}
$for(babel-otherlangs)$
\babelprovide[import]{$babel-otherlangs$}
$endfor$
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
$endif$

\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi

\ifPDFTeX
  \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
$if(mathspec)$
  \ifXeTeX
    \usepackage{mathspec}
  \else
    \usepackage{unicode-math}
  \fi
$else$
  \usepackage{unicode-math}
$endif$

\usepackage{parskip}

\usepackage{graphics}

\usepackage{booktabs}
\usepackage{longtable}

\usepackage[right]{eurosym}

\usepackage{enumitem}

\makeatletter
    \setlength{\@tempskipa}{-1.2cm}%
    \@addtoplength{toaddrheight}{\@tempskipa}
\makeatother

\setlength{\oddsidemargin}{\useplength{toaddrhpos}}
\addtolength{\oddsidemargin}{-1in}
\setlength{\textwidth}{\useplength{firstheadwidth}}

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

\begin{document}%
    \setkomavar{fromname}{$author$}%
    \renewcommand*{\raggedsignature}{\raggedright}%
    \setkomavar{fromaddress}{%
        $for(return-address)$%
            $return-address$$sep$\\
        $endfor$
    }
    \setkomavar{fromphone}{$phone$}
    \setkomavar{fromemail}{$email$}
    \setkomavar{signature}{$author$}

    \setkomavar{date}{$date$}
    \setkomavar{place}{$place$}

    \setkomavar{subject}{$subject$}

    \begin{letter}{%
        $for(address)$
            $address$$sep$\\
        $endfor$  
    }

        \opening{$opening$}

        $body$

        \closing{$closing$}

        \ps $postskriptum$

        $if(encludes)$
            \setkomavar*{enclseparator}{Anlage}
            \encl{$encludes$}
        $endif$
    \end{letter}
\end{document}
