kbrw / mailibex Goto Github PK
View Code? Open in Web Editor NEWLibrary containing Email related implementations in Elixir : dkim, spf, dmark, mimemail, smtp
License: MIT License
Library containing Email related implementations in Elixir : dkim, spf, dmark, mimemail, smtp
License: MIT License
Apart from a bunch of compiler warnings about deprecated stuff,
== Compilation error in file lib/dmarc.ex ==
** (CompileError) Elixir.DMARC: function organization/1+79850:
Internal consistency check failed - please report this bug.
Instruction: {test,bs_test_tail2,{f,8268},[{x,14},0]}
Error: {no_bsm_context,{x,14}}:
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
I haven't been able to find out when/why this happens exactly yet, logging an issue so we can coordinate work if more people are looking at this.
NIFs should be generally avoided for production environments (unless they can be placed on a separate BEAM node). This is because NIFs causes scheduling problems in BEAM VM when there are hundreds of concurrent users.
Provide config option for user to avoid NIFs altogether.
Compiling on Elixir 1.2.5 causes ugly compiler warnings that indicate bad code path.
Compiled lib/mimemail_headers.ex
lib/mime_types.ex:17: warning: this clause cannot match because a previous clause at line 17 always matches
lib/mime_types.ex:17: warning: this clause cannot match because a previous clause at line 17 always matches
Investigate, adapt, commit
I have
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: 8bit
and
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: 8bit
And body content is not parsed when I am using
raw_imap_response
|> MimeMail.from_string
|> MimeMail.decode_body
Email is from gramarly it will be attached in file. Can someone please take a look?
Thanks
gramarly.zip
Possible Denial Of Service attack
See:
https://github.com/awetzel/mailibex/blob/master/lib/mimemail.ex#L22
@GuillaumeMilan
Hi, I saw that recently You've updated the package to resolve compile-time warnings, could you release a new version to hex? Or there is something needed to do that. If yes, can I help you some way?
I have a huge message from aliexpress that when passed through Dkim.sign comes out encoded as base64 and gmail doesn't really like it. If i change the content type to "multipart/alternative" it doesn't end up as base64. I tried to shink it down but that doesn't impact it.
here's the test msg redacted a bit
Received: from out24-13.mail.alibaba.com (out24-13.mail.alibaba.com [115.124.24.13])
by myemail.net (Postfix) with ESMTP id C0EE340438
for [email protected]; Mon, 8 Nov 2021 14:05:19 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.10.3 myemail.net C0EE340438
Authentication-Results: myemail.net;
dkim=pass (1024-bit key) header.d=mail.aliexpress.com [email protected] header.b=aqadJZh+
X-AliDM-RcptTo: YWI1MzdjMWE5NzRmMzQ0YzU4Yzc5ZjU1ZDRmYWI1NDk4QGJybmcudXM=
Feedback-ID: default:[email protected]:batch:13
DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed;
d=mail.aliexpress.com; s=s1024;
t=1636380318; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type;
bh=ir/1fYnPPk+nKtectnb5YsqowhiW9rE7NTu4dGwaXeY=;
b=aqadJZh+vBA1XUX2bye/ZDsukKYQaOOqpTb9NJVYc4qe+dKpNxs2rpdKQVFc/p0OouHn4NAmeRv3rRqzmS8TUdEAAMCplHhBoAEs9UN1nWLQ0M0YcM14O1SySV4W/5wTpAzM/Q7ytLXh4Yx/0DN/h00/6cA8NvDZX2LTlPo2xWI=
X-EnvId: 194285051284
Received: from ae-buyer-user9f74-xxfn8(mailfrom:[email protected] fp:SMTPD_----0owGdlt)
by smtp.aliyun-inc.com(127.0.0.1);
Mon, 08 Nov 2021 22:05:17 +0800
Date: Mon, 8 Nov 2021 06:05:17 -0800 (PST)
From: AliExpress <[email protected]>
To: [email protected]
Message-ID: 3197biz_price_reduce_edm:0:0_4659037$074e0a7ae314499f960e4e47fa388cfa
Subject: New price alert for bob
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_133763949_30120080.1636380317614"
------=_Part_133763949_30120080.1636380317614
Content-Type: text/html;charset=utf-8
Content-Transfer-Encoding: quoted-printable
<!--aeug_edm_19435#${houyiJobId}--><!doctype html>
<html xmlns=3D"http://www.w3.org/1999/xhtml" xmlns:v=3D"urn:schemas-microso=
ft-com:vml" xmlns:o=3D"urn:schemas-microsoft-com:office:office">
<head>=20
<meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale=3D=
1">=20
</head>=20
<body style=3D"background: #fff; background-color: #fff;">=20
</div> =20
</body>
</html><div style=3D"display:none"><img style=3D"display:none" src=3D"http:=
//ae.mmstat.com/ae.edm.edm_open?tracelog=3Drowan-ae_usertouch-aeug_edm_1943=
5_1_en_US-2021-11-08&rowan_msg_id=3D3197biz_price_reduce_edm:0:0_4659037$07=
4e0a7ae314499f960e4e47fa388cfa"/></div>
------=_Part_133763949_30120080.1636380317614--
here's the code that calls the signing
def sign(mail_pipe) do
if mail_pipe.domain == :error, do: raise "signing... domain error"
[rsaentry] = :public_key.pem_decode(File.read!(@privkey))
new_mail = %MimeMail{headers: mail_pipe.stripped_headers,body: mail_pipe.new_mm.body}
to_addresses = Enum.map(mail_pipe.to_list, fn(x) ->
x.new.address
end)
key = :public_key.pem_entry_decode(rsaentry)
#
# Seems fine until this point and it gets base64 encoded
#
signed_mail = DKIM.sign(new_mail,key,d: mail_pipe.domain,s: "mail")
raw_signed_mail = MimeMail.to_string(signed_mail)
Idg.MP.print_report(mail_pipe)
r = {mail_pipe.from.new.address,to_addresses,raw_signed_mail}
end
Mailibex cannot be used on windows as MimeMail Iconv module fails to load due to missing iconv NIF dll.
Currently only iconv_nif.so is included in binary distribution on hex.pm.
Either include iconv_nif.dll into binary distribution on hex.pm, or update Mix compile instructions for Windows users.
Great library btw!!!!
The following is parsed incorrectly
X-Mailer: MIME::Lite 3.028 (F2.82; T1.31; A2.08; B3.13; Q3.13)
From: "craigslist - automated message, do not reply" <[email protected]>
To: [email protected]
Subject: craigslist.org:
here is the resulting parsed terms
[%MimeMail.Address{address: "\"craigslist - automated message", name: nil}, %MimeMail.Address{address: "[email protected]", name: "do not reply\""}]
It does not seem to compile currently.
Steps:
{:mailibex, "~> 0.1.4"},
to the deps.mix deps.get
mix compile
or iex -S mix
, which crashes:** (CompileError) Elixir.DMARC: function organization/1+81247:
Internal consistency check failed - please report this bug.
Instruction: {test,bs_test_tail2,{f,8408},[{x,14},0]}
Error: {no_bsm_context,{x,14}}:
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
Parts with empty body causes MimeMail.decode_body to fail due to match error.
I'm using mailibex
in my project and every day I see
warning: module attribute @shortdoc was set but never used
/.../project/deps/mailibex/mix.exs:2
multiple times and it's annoying (because I keep thinking I introduced it).
Would you be opposed to its removal?
How do I get attachments from an email binary?
wondering if the other branch which includes the change to crypto:strong_rand_bytes/1 will get merged soon?
This project is nice, would like to contribute. It would be nice if you could publish a barebones smtp server and client implementation to get us started.
@moduledoc
and @doc
elixir_make
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.