Code Monkey home page Code Monkey logo

go-mime-message's People

Contributors

sloonz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-mime-message's Issues

Error sending Multipart messages

Hi,

I am trying to send an email with attachments but I only receive one part:

  • If I add both parts I get only the text without the attachment.
  • If I add only part1 I get the text.
  • If I add only part2 I get the text attached as "noname".

this is the code:

package main

import (
    "bytes"
    "errors"
    "github.com/sloonz/go-mime-message"
    "github.com/sloonz/go-qprintable"
    "log"
    "net/smtp"
)

func main() {
    m := message.NewMultipartMessage("alternative", "")
    m.SetHeader("Subject", message.EncodeWord("test"))

    m1 := message.NewTextMessage(qprintable.UnixTextEncoding, bytes.NewBufferString("this is the text body."))
    m1.SetHeader("Content-Type", "text/plain")
    m.AddPart(m1)

    m2 := message.NewBinaryMessage(bytes.NewBufferString("this is some text as attachment."))
    m2.SetHeader("Content-Type", "application/octet-stream")
    m.AddPart(m2)

    var buf bytes.Buffer
    buf.ReadFrom(m)

    erri := smtp.SendMail(
        "mail.padelclick.com:25",
        smtp.PlainAuth("", "test", "test", "mail.example.com"),
        "[email protected]",
        []string{"[email protected]"},
        buf.Bytes())
}

How to add MultipartMessage as part of another MultipartMessage

I need to encode a multipart/mixed as part of a multipart/alternative, that means a MultipartMessage as part of a MultipartMessage.

The problem is MultipartMessage.AddPart only supports *Message.

Is there a way one can convert a *MultipartMessage into a *Message?

Headers not written for multipart messages

MultipartMessage takes responsibility for printing each Message's headers before their bodies, but there ought to be a way to write a MultipartMessage with its headers, too. Reading from Body doesn't do the trick (though it probably shouldn't):

msg := mimeMessage.NewMultipartMessage("related", randomBoundary())
io.Copy(os.Stdout, msg.Body)

only prints:

--xxx

instead of:

Content-Type: multipart/related; boundary="xxx"

--xxx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.