# Admin-API - Mailversand mit Anhang

**URL:** <https://forum.shopware.com/t/admin-api-mailversand-mit-anhang/98209>\
**Category:** Programmierung\
**Created:** [26. Januar 2023 um 09:11 UTC](https://forum.shopware.com/t/admin-api-mailversand-mit-anhang/98209 "2023-01-26T09:11:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![web-grips](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/web-grips/32/22792_2.png) [@web-grips](https://forum.shopware.com/u/web-grips)\
**Post date:** [26. Januar 2023 um 09:11 UTC](https://forum.shopware.com/t/admin-api-mailversand-mit-anhang/98209/1 "2023-01-26T09:11:12Z")

</div>

wir versenden Mails über die Admin-API, bei PDF-Anhängen ist das PDF anschließend nicht lesbar, bei TXT Dateien gibt es kein Problem.

> **[Send a mail | Admin API](https://shopware.stoplight.io/docs/admin-api/743f0819350c4-send-a-mail)**
>
> Generates a mail from a mail template and sends it to the customer.
> 
> Take a look at the \`salesChannel\` entity for possible values. For example \`{{ salesChannel.name }}\` can be used. Powered by Stoplight.

Request-URL: \_action/mail-template/send

Wir nutzen dafür den Parameter binAttachments der wie folgt gesetzt ist.  
Der „Content“ wird geholt und ohne BASE64 Kodierung ist der JSON-Code korrupt, wenn man ihn codiert kann die Mail gesendet werden. Aber der Anhang ist mit Kodierung nicht gültig und die Datei ist korrupt.

$content = file\_get\_contents()  
$binAttachments = [„content“ =\> base64\_encode($content),  
„fileName“ =\> ‚test.pdf‘,  
„mimeType“ =\> ‚application/pdf‘  
];

Wie muss der Content richtig gesetzt werden?
