\documentclass[
    $if(phone)$    fromphone,$endif$
    $if(email)$    fromemail,$endif$
$for(letteroption)$
    $letteroption$$sep$,
$endfor$
]{scrlttr2}

% Fonts
% Inspired from https://github.com/aaronwolen/pandoc-letter
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
$for(fontfamilies)$
  \newfontfamily{$fontfamilies.name$}[$fontfamilies.options$]{$fontfamilies.font$}
$endfor$
$if(mainfont)$
    \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
$endif$
$if(sansfont)$
    \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
$endif$
$if(monofont)$
    \setmonofont[Mapping=tex-ansi$if(monofontoptions)$,$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$endif$]{$monofont$}
$endif$
$if(mathfont)$
$if(mathspec)$
  \ifxetex
    \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
  \else
    \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
  \fi
$else$
  \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
$endif$
$endif$
$if(CJKmainfont)$
  \ifxetex
    \usepackage{xeCJK}
    \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
  \fi
$endif$
$if(luatexjapresetoptions)$
  \ifluatex
    \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}
  \fi
$endif$
$if(CJKmainfont)$
  \ifluatex
    \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}
    \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
  \fi
$endif$
% End of Fonts

\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{csquotes} % German quotation marks

\usepackage{graphics}

\usepackage{booktabs}
\usepackage{longtable}

\usepackage[right]{eurosym}

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

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

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

\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$}

    $if(date)$\setkomavar{date}{$date$}$endif$
    \setkomavar{place}{$place$}

    $if(subject)$\setkomavar{subject}{$subject$}$endif$

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

        \opening{$opening$}

        $body$

        \closing{$closing$}

        $if(ps)$\ps $ps$$endif$

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