Giter VIP home page Giter VIP logo

smtpkitten's Introduction

Joannis Header

๐Ÿ‘‹ Hey! I'm Joannis, co-founder of Unbeatable Software B.V..

I maintain a lot of Swift Projects, in particular for Server-Side Swift. I'm also a member of the Swift Server WorkGroup.

Read my blog posts, articles and newsletter

In addition to my OpenSource work - listed below - I'm also providing services such as Code Review, Swift Backend Development, iOS/macOS Development and Mentoring.

Backend Focussed Projects

These projects focus on Linux & macOS, but also support iOS in most cases through NIOTransportServices.

High Profile

Low Profile

General Swift Projects

These projects support iOS, macOS and Linux + aim to support Android & Windows.

High Profile

Low Profile

  • TaskQueue - speaks for itself (deprecated)
  • SC2Kit - Write StarCraft 2 bots in Swift

Things I'm Tracking

Vapor

  1. GraphQL Server w/ Vapor
  2. PNG and JPEG in Swift
  3. QRCodeGenerator for any platform in Swift

iOS

  1. GraphQL Client

Server

  1. https://github.com/funcmike/rabbitmq-nio
  2. https://github.com/adam-fowler/compress-nio

Embedded:

  1. https://madmachine.io
  2. Custom Swift stdlib for low-resource environments
  3. Bare Metal Kernel in Swift

Multiplatform

  1. Swift on Android and Another One
  2. Win32 for Swift on Windows
  3. Swift in the Webbrowser with a matching UI Framework
  4. Swift UI Applications on Linux using GTK
  5. Swift + NodeJS Bindings
  6. Swift + Python Bindings

Also Cool

  1. DirectX in Swift
  2. State Synchronization between clients

smtpkitten's People

Contributors

joannis avatar petrpavlik avatar skatbox avatar tierracero 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

Watchers

 avatar  avatar  avatar

smtpkitten's Issues

Cant supply multiply To: receipients

I am trying to send emails through Vapor (have tried VaporSMTPKit) seems to be a underlying bug with SMTPKitten and gmail where if you supply multiply receiptants for an email send and func status(_ status: SMTPResponseCode...) only gets called once not twice

`
app.get("test", "two") { req -> EventLoopFuture in

    let mail = Mail(
        from: MailUser(name: "Test", email: "[email protected]"),
        to: ["[email protected]", "[email protected]"],
        subject: "Welcome to our app!",
        contentType: .plain,
        text: "Welcome to our app, you're all set up & stuff."
    )

    return SMTPClient.connect(
        hostname: "smtp.gmail.com",
        ssl: .startTLS(configuration: .default),
        eventLoop: req.eventLoop
    ).flatMap { client in
        client.login(
            user: "[email protected]",
            password: "ZXCzxc123"
        ).flatMap {
            client.sendMail(mail)
        }
    }.map {
        "Done"
    }
    
    
    
}`

HTML showing as plain text in microsoft email services.

Every time I send out email as html as the content type, the email is showing as plain text if the receiver has an outlook, live or hotmail domains. Or basically anything microsoft hosted domains (included business emails that uses office365)

Mail.Content.alternative(emailText, html: emailHtml) Doesn't work correctly

Describe the bug
I assume that Mail.Content.alternative(emailText, html: emailHtml) is suppose to provide both text and HTML and allow the client to decide which one it can display. When I try to use it my Gmail client's raw view of the email looks like this:

--B9D183B2-5135-4FC1-B0EE-3D627C98443F Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8BIT Test email! --B9D183B2-5135-4FC1-B0EE-3D627C98443F Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8BIT
  <html> <body>
   Test email! </body> </html> --B9D183B2-5135-4FC1-B0EE-3D627C98443F--


--B9D183B2-5135-4FC1-B0EE-3D627C98443F--

Notice that there is no newline after Content-Transfer-Encoding: 8BIT and before the text "Test email!" for the plain text. This email didn't render within Gmail at all. The body was blank

To Reproduce

    let emailText = """
Test email!
"""
    let emailHtml = """
<html>
<body>
  Test email!
</body>
</html>
"""
    let email = Mail(
      from: .defaultSender,
      to: [MailUser(name: nil, email: email)],
      subject: "This is a Test Email") {
        Mail.Content.alternative(emailText, html: emailHtml)
      }
    try await send(mail: email)

Expected behavior
I think what's suppose to happen is that Gmail is suppose to display the HTML version. The Text version should appear for text only clients.

Details:

  • OS: 14.3.1 (23D60)
  • Release 0.2.3
  • SMTP Server exim

Additional context
I was playing around with the client and observed this. I don't use this feature, but thought it would help improve the library and maybe highlight other related bugs.

This issue might be related to my other "\n" vs "\r\n" issue.

Need to replace "\n" with "\r\n"

Describe the bug
SMTP expects "\r\n" for new line. If the HTML or plaintext is encoded using "\n" then it does not turn into a new line. Something ends up stripping it. The email delivery failed for me with message: message has lines too long for transport. This is because my whole email turned into a single line and hit the max line length limit.

To Reproduce

    let verifyEmailUrl = app.publicBaseUrl + AuthenticationController.baseVerifyEmailPath + "?token=" + token
    let context = VerifyEmailContext(emailVerificationLink: verifyEmailUrl)
    let view: View = try await view.render("emails/verify_email", context)
    let emailHtml = String(buffer: view.data) //.replacingOccurrences(of: "\n", with: "\r\n")
    let email = Mail(
      from: .defaultSender,
      to: [MailUser(name: nil, email: email)],
      subject: "Verify Your xxx Email") {
        Mail.Content.html(emailHtml)
      }
    try await send(mail: email)

Expected behavior
It should be documented somewhere that you should .replacingOccurrences(of: "\n", with: "\r\n") for all text or html inputs. Or the library should do it by default and have a flag to disable the replacement if someone's input is already properly using "\r\n".

You can also log a "warning" if you see "\n" being used as a line break.

Details:

  • OS: macOS 14.3.1
  • Release: 0.2.3
  • SMTP Server: Exim? Default for Cpanel

Additional context
Add any other context about the problem here.

It took me a long time to figure out that this was the issue. Cpanenl kept rejecting the email with "message has lines too long for transport" and I tried to play around with the line length of my message. Little did I know that the whole message was being treated as a single line. So after the email was certain characters long it would hit the exim's max line limit and return the error. Even if nothing comes of this issue, at least it will show up for other when searching.

VaporSMTPKit Does Not Load

Hi. When I try to load VaporSMTPKit which depends on SMTPKitten I am now getting the following error:

when I now update the package I get the following errors

SMTPClient has no member flatMap
Generic parameter T could not be inferred in sent = mails.
in:

return SMTPClient.connect(
hostname: credentials.hostname,
port: credentials.port,
ssl: credentials.ssl,
eventLoop: self.eventLoopGroup.next()
).flatMap { client in
client.login(
user: credentials.email,
password: credentials.password
).flatMap {
let sent = mails.map(client.sendMail)
return EventLoopFuture.andAllSucceed(sent, on: self.eventLoopGroup.next())
}
}

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.