@@ -80,23 +80,33 @@ type SendRequest struct {
8080 Subject string
8181
8282 // Message body (text)
83- // example: This is the text body
83+ // example: Mailpit is awesome!
8484 Text string
8585
8686 // Message body (HTML)
87- // example: <p style="font-family: arial">Mailpit is <b>awesome</b>!</p>
87+ // example: <div style="text-align:center">< p style="font-family: arial; font-size: 24px; ">Mailpit is <b>awesome</b>!</p><p><img src="cid:mailpit-logo" /></p></div >
8888 HTML string
8989
9090 // Attachments
9191 Attachments []struct {
9292 // Base64-encoded string of the file content
9393 // required: true
94- // example: VGhpcyBpcyBhIHBsYWluIHRleHQgYXR0YWNobWVudA==
94+ // example: iVBORw0KGgoAAAANSUhEUgAAAEEAAAA8CAMAAAAOlSdoAAAACXBIWXMAAAHrAAAB6wGM2bZBAAAAS1BMVEVHcEwRfnUkZ2gAt4UsSF8At4UtSV4At4YsSV4At4YsSV8At4YsSV4At4YsSV4sSV4At4YsSV4At4YtSV4At4YsSV4At4YtSV8At4YsUWYNAAAAGHRSTlMAAwoXGiktRE5dbnd7kpOlr7zJ0d3h8PD8PCSRAAACWUlEQVR42pXT4ZaqIBSG4W9rhqQYocG+/ys9Y0Z0Br+x3j8zaxUPewFh65K+7yrIMeIY4MT3wPfEJCidKXEMnLaVkxDiELiMz4WEOAZSFghxBIypCOlKiAMgXfIqTnBgSm8CIQ6BImxEUxEckClVQiHGj4Ba4AQHikAIClwTE9KtIghAhUJwoLkmLnCiAHJLRKgIMsEtVUKbBUIwoAg2C4QgQBE6l4VCnApBgSKYLLApCnCa0+96AEMW2BQcmC+Pr3nfp7o5Exy49gIADcIqUELGfeA+bp93LmAJp8QJoEcN3C7NY3sbVANixMyI0nku20/n5/ZRf3KI2k6JEDWQtxcbdGuAqu3TAXG+/799Oyyas1B1MnMiA+XyxHp9q0PUKGPiRAau1fZbLRZV09wZcT8/gHk8QQAxXn8VgaDqcUmU6O/r28nbVwXAqca2mRNtPAF5+zoP2MeN9Fy4NgC6RfcbgE7XITBRYTtOE3U3C2DVff7pk+PkUxgAbvtnPXJaD6DxulMLwOhPS/M3MQkgg1ZFrIXnmfaZoOfpKiFgzeZD/WuKqQEGrfJYkyWf6vlG3xUgTuscnkNkQsb599q124kdpMUjCa/XARHs1gZymVtGt3wLkiFv8rUgTxitYCex5EVGec0Y9VmoDTFBSQte2TfXGXlf7hbdaUM9Sk7fisEN9qfBBTK+FZcvM9fQSdkl2vj4W2oX/bRogO3XasiNH7R0eW7fgRM834ImTg+Lg6BEnx4vz81rhr+MYPBBQg1v8GndEOrthxaCTxNAOut8WKLGZQl+MPz88Q9tAO/hVuSeqQAAAABJRU5ErkJggg==
9595 Content string
9696 // Filename
9797 // required: true
98- // example: AttachedFile.txt
98+ // example: mailpit.png
9999 Filename string
100+ // Optional Content Type for the the attachment.
101+ // If this field is not set (or empty) then the content type is automatically detected.
102+ // required: false
103+ // example: image/png
104+ ContentType string
105+ // Optional Content-ID (`cid`) for attachment.
106+ // If this field is set then the file is attached inline.
107+ // required: false
108+ // example: mailpit-logo
109+ ContentID string
100110 }
101111
102112 // Mailpit tags
@@ -269,9 +279,15 @@ func (d SendRequest) Send(remoteAddr string) (string, error) {
269279 if err != nil {
270280 return "" , fmt .Errorf ("error decoding base64 attachment \" %s\" : %s" , a .Filename , err .Error ())
271281 }
272-
273- mimeType := http .DetectContentType (b )
274- msg = msg .AddAttachment (b , mimeType , a .Filename )
282+ contentType := http .DetectContentType (b )
283+ if a .ContentType != "" {
284+ contentType = a .ContentType
285+ }
286+ if a .ContentID != "" {
287+ msg = msg .AddInline (b , contentType , a .Filename , a .ContentID )
288+ } else {
289+ msg = msg .AddAttachment (b , contentType , a .Filename )
290+ }
275291 }
276292 }
277293
0 commit comments