fewlinesco / bamboo_smtp Goto Github PK
View Code? Open in Web Editor NEWAn SMTP adapter for Bamboo.
License: MIT License
An SMTP adapter for Bamboo.
License: MIT License
When sending emails with version 3.1.0, my ASCII subject lines are displayed incorrectly in mail clients, for example: H_Ui"bvu7
.
This seems to be related to the following call -
bamboo_smtp/lib/bamboo/adapters/smtp_adapter.ex
Lines 204 to 210 in 59dd510
Isn't "=?UTF-8?B?#{content}?="
saying that this string is a UTF-8 character set, encoded in Base64 but without actually encoding the content in Base64?
Just returning content
for only ASCII characters fixed my issue.
defp rfc822_encode(content) do
if contains_only_ascii_characters?(content) do
content
else
"=?UTF-8?B?#{Base.encode64(content)}?="
end
end
Any reason to just support bamboo ~> 0.5.0
? 0.6.0 has been released. Is it possible to bump the dependency?
The following warnings are observed on
Elixir 1.8.1 (compiled with Erlang/OTP 21)
src/smtp_util.erl:71: Warning: crypto:rand_uniform/2 is deprecated and will be removed in a future release; use rand:uniform/1
src/smtp_util.erl:71: Warning: crypto:rand_uniform/2 is deprecated and will be removed in a future release; use rand:uniform/1
src/socket.erl:124: Warning: ssl:ssl_accept/1: deprecated; use ssl:handshake/1 instead
src/socket.erl:233: Warning: ssl:ssl_accept/3: deprecated; use ssl:handshake/3 instead
My SMTP server works when I telnet to it - but using my Phoenix app spits this out into the erlang.log.4
=CRASH REPORT==== 29-Jul-2017::17:07:15 ===
crasher:
initial call: Elixir.Bamboo.TaskSupervisorStrategy:-deliver_later/3-fun-0-/0
pid: <0.1563.0>
registered_name: []
exception exit: {#{'__exception__' => true,
'__struct__' => 'Elixir.Bamboo.SMTPAdapter.SMTPError',
message => <<"There was a problem sending the email through SMTP.\n\nThe error is :no_more_hosts\n\nMore detail below:\n\n{:permanent_failure, '10.0.0.141', \"501 Syntax error in parameters or arguments.\\r\\n\"}\n">>,
raw => {no_more_hosts,
{permanent_failure,"10.0.0.141",
<<"501 Syntax error in parameters or arguments.\r\n">>}}},
[{'Elixir.Bamboo.SMTPAdapter',handle_response,1,
[{file,"lib/bamboo/adapters/smtp_adapter.ex"},
{line,80}]},
{'Elixir.Task.Supervised',do_apply,2,
[{file,"lib/task/supervised.ex"},{line,94}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]}
in function 'Elixir.Task.Supervised':exit/4 (lib/task/supervised.ex, line 125)
ancestors: ['Elixir.Bamboo.TaskSupervisor','Elixir.Bamboo.Supervisor',
<0.1286.0>]
messages: []
links: [<0.1289.0>]
dictionary: []
trap_exit: false
status: running
heap_size: 2586
stack_size: 27
reductions: 4790
neighbours:
If anyone can help me rigth now - it would really be a big favour to 35000 scouts currently camping on a jamboree in Denmark (http://spejderneslejr.dk/en)
Hello,
I have a little issue with your lib. After setup Bamboo into my project see below the conf :
config :test_phoenix, TestPhoenix.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "smtp.my_server.com",
port: 25,
username: "user",
password: "paSSwork",
tls: :never, # can be `:always` or `:if_available`
ssl: false # can be `true`
I got this error:
[error] Task #PID<0.1100.0> started from #PID<0.1098.0> terminating
** (Bamboo.SMTPAdapter.SMTPError) There was a problem sending the email through SMTP.
The error is :retries_exceeded
More detail below:
{:network_failure, "smtp.my_server.co", {:error, :timeout}}
lib/bamboo/adapters/smtp_adapter.ex:74: Bamboo.SMTPAdapter.handle_response/1
(elixir) lib/task/supervised.ex:94: Task.Supervised.do_apply/2
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<0.115485522/0 in Bamboo.TaskSupervisorStrategy.deliver_later/3>
Args: []
So I check online if I can send an email with http://smtper.nanogenesis.fr/
with the same param. And I got the email!!!
So I do not know what I did wrong!!!
PS: The server email is postfix version 2.6.6
Amazon SES returns a message-id when sending emails via them which then can be used to match against with bounce and other notifications. Is there a way to get this information?
When I add bamboo_smtp as dependency on mix.exs
following the README or as: {:bamboo_smtp, github: "fewlinesco/bamboo_smtp"}
and then run mix deps.get
, I get this error:
Failed to use "ranch" (version 1.6.2) because
cowboy (versions 2.7.0 and 2.8.0) requires ~> 1.7.1
gen_smtp (version 1.0.1) requires 1.6.2
How I could proceed?
while sending email thorugh MyApp.Mailer.deliver_now I am getting the following error
{:network_failure, 'smtp.gmail.com', {:error, :econnrefused}}
forwarding through POP/IMAP is on in gmail
Please help.
Thanks in advance
I want to send different emails from different accounts of the same server. How can I specify username/password per email?
Relax bamboo dependency as a new release has been published.
Noticed this due a lovely @dependabot automatic PR where it couldn't give us a shortlist of the commits between 1.6.0 and 1.7.0.
I am getting this error when trying to send an email:
{:network_failure, 'smtp.office365.com', {:error, {:tls_alert, 'bad record mac'}}}
(bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:96: Bamboo.SMTPAdapter.handle_response/1
(bamboo) lib/bamboo/mailer.ex:145: Bamboo.Mailer.deliver_now/4
server: "smtp.office365.com",
username: "[email protected]",
password: "somepass",
port: 587,
ssl: true,
tls: :always,
allowed_tls_versions: [:"tlsv1.2"],
auth: :always,
retries: 1
There are several other applications on my computer (Microsoft Outlook, as well as another .NET application) that can send emails via this SMTP server without issues. However, my Phoenix application fails with the above error.
edit: I should mention that I'm on Windows 10. I just tried on another Windows 10 machine and got the same error.
Hi there,
We're seeing the following entries in the log of one of our service that make use of bamboo_smtp. Would be possible to catch those throws from the gen_smtp_client library and re-raise SMTPError
so we can debug what is missing. Or if there is other way to debug this?
I would say reading the bamboo
code that a validation and normalization of addresses happens before delivering the email so shouldn't that catch this issues?
Thanks in advance
Hi.
I have an email that is sent to a user defined list of recipients, and it bcc'ed to a app-level list of recipients. If the user leaves the to
recipients empty, I want the email to still go out to the bcc
recipients.
I am using Amazon SES.
Is there a problem sending emails without any recipients in the to
header, if there are recipients in the bcc
header?
The error I am getting is:
** (Bamboo.SMTPAdapter.SMTPError) There was a problem sending the email through SMTP.
The error is :no_more_hosts
More detail below:
{:permanent_failure, 'email-smtp.us-west-2.amazonaws.com', "554 Transaction failed: Empty required header 'To'.\r\n"}
For clarity, the emails send fine if there is one or more email addresses defined by the user.
Hey,
There where some changes in the last 5 months and it would be great to bump the version and publish to hex.
Hi,
thanks for the adapter.
How can i catch an error? For example if the email is not verified. Iยดd like to write
"554 Message rejected: Email address is not verified.
into the database.
In a production environments, build with exrm for instance, you also have to specify :bamboo_smtp
in application:
def application do
[applications: [:bamboo, :bamboo_smtp]]
end
Without :bamboo_smtp
, it occurred an error like following(I was able to send it with :bamboo_smtp
):
** (exit) an exception was raised:
** (UndefinedFunctionError) function Bamboo.SMTPAdapter.deliver/2 is undefined (module Bamboo.SMTPAdapter is not available)
I am using bamboo
and bamboo_smtp
to send a text email with a PDF file as an attachment. The PDF file is ~1.8MB. Memory usage consistently hovered around 1.7MB as the %Bamboo.Email
is generated. However on calling .deliver
, memory usage grew to ~2.5 GB. This increase in memory usage was also observed for emails without attachments, although the increase was not as drastic. Is this expected behaviour?
bamboo
version v1.0.0
bamboo_smtp
version v1.5.0
Also fix deprecations in tests for Elixir 1.4.0
When I try to send a stripped down email:
Bamboo.Email.new_email(
from: {"No Reply", "[email protected]"},
to: [{"Some Guy", "[email protected]"}],
subject: "Winner Winner",
html_body: "<strong>Bamboo is awesome!</strong>",
text_body: "*Bamboo is awesome!*",
headers: %{
"Reply-To" => "[email protected]"
})
|> Mailer.deliver_now
I am getting an odd error,
no function clause matching in :gen_smtp_client.to_string/1
Is there some call signature im missing, or am I setting this up wrong? I follow the instructions for set up as closely as I could, and no matter what I do it seems to keep throwing this error.
Any help with this would be fgreat.
I noticed that thoughtbot recently shipped v1 of Bamboo. I've seen a few release candidates for 1.5 that support the newest version. I would be happy to help out if there is anything that needs to be done to support the release.
Process #PID<0.32722.14> terminating: {:function_clause, [{Base, :encode64, [nil, []], [file: 'lib/base.ex', line: 278]}, {Bamboo.SMTPAdapter, :rfc822_encode, 1, [file: 'lib/bamboo/adapters/smtp_adapter.ex', line: 149]}, {Bamboo.SMTPAdapter, :add_subject, 2, [file: 'lib/bamboo/adapters/smtp_adapter.ex', line: 145]}, {Bamboo.SMTPAdapter, :body, 1, [file: 'lib/bamboo/adapters/smtp_adapter.ex', line: 190]}, {Bamboo.SMTPAdapter, :to_gen_smtp_message, 1, [file: 'lib/bamboo/adapters/smtp_adapter.ex', line: 282]}, {Bamboo.SMTPAdapter, :deliver, 2, [file: 'lib/bamboo/adapters/smtp_adapter.ex', line: 61]}, {Task.Supervised, :do_apply, 2, [file: 'lib/task/supervised.ex', line: 85]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}
Backtrace
(bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:149: Bamboo.SMTPAdapter.rfc822_encode/1
(bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:145: Bamboo.SMTPAdapter.add_subject/2
(bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:190: Bamboo.SMTPAdapter.body/1
(bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:282: Bamboo.SMTPAdapter.to_gen_smtp_message/1
(bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:61: Bamboo.SMTPAdapter.deliver/2
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Mail still sends, this error doesn't show up every time, just sometimes.
The release of Erlang/OTP 22 brought a new :socket
API, creating a name conflict between gen_smtp and OTP (see http://blog.erlang.org/OTP-22-Highlights/). gen_smtp released a new version to address this issue. Can you please update dependencies?
Thanks to #122 we can now provide a response: true
flag when sending an email, however when using this flag in combination with a config:
map, the whole thing errors:
config = %{server: "..."}
BambooTrial.Mailer.deliver_now(BambooTrial.Email.test_email(), config: config, response: true)
errors with:
** (ArgumentError) The following settings have not been found in your settings:
* Key port is required for SMTP Adapter
* Key server is required for SMTP Adapter
They are required to make the SMTP adapter work. Here you configuration:
%{adapter: Bamboo.SMTPAdapter}
(bamboo_smtp 2.1.0) lib/bamboo/adapters/smtp_adapter.ex:342: Bamboo.SMTPAdapter.raise_on_missing_configuration/2
(bamboo_smtp 2.1.0) lib/bamboo/adapters/smtp_adapter.ex:84: Bamboo.SMTPAdapter.handle_config/1
(bamboo 1.5.0) lib/bamboo/mailer.ex:292: Bamboo.Mailer.handle_adapter_config/1
attachment with extension "eml" ("message/rfc822") transform to noname empty file when sent to receiver
Spam filters dislike base64-encoded email headers, as it was used to circumvent earlier spam filters. click However, the adapter always base64-encodes, regardless of whether it is actually necessary.
Can we extend the rfc822_encode
method to check before base64 encoding if there are actually any non-ascii-127 characters in the data?
I would be willing to help with a PR...
We started by just adding the attachments as base64 encoded data in the right place of the email. It was a simple implementation.
With the pull-request #137, we discovered the way we encode attachment can be related to the content-type of the attachment.
When we added the fixes, we had to split logic in two different places:
If we start to split the logic in different places I'm a bit afraid the maintenance will become harder when we add more kind of attachments.
We need to think / draft how to refactor this part of the library to make it easier to add support for new kind of attachments.
Is there a trick (or a bug ?) in the fact that content of HTML emails are just not displayable in emails clients except gmail ?
Hello,
i try to connect to a smtp server per ipv6 - which was not possible, even with:
family: :inet6
as parameter (and hacky by change it in code here):
I always got:
{:network_failure, 'mx01.example.org', {:error, :enetunreach}}
hello
what about the cram md5 authentication ?
Email are not received, but no errors shown for an smtp server that requires cram-md5
thanks
Here my configuration:
config :panda_phoenix, PandaPhoenix.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "smtp.my_site.com",
port: 465,
username: "my_user_name",
password: "my_password",
auth: :always,
tls: :always, # can be `:always` or `:if_available`
allowed_tls_versions: [:"tlsv1", :"tlsv1.1", :"tlsv1.2"],
ssl: true, # can be `true`
retries: 4
Error:
[error] Task #PID<0.1099.0> started from #PID<0.1096.0> terminating
** (Bamboo.SMTPAdapter.SMTPError) There was a problem sending the email through SMTP.
The error is :retries_exceeded
More detail below:
{:missing_requirement, "smtp.my_site.com", :tls}
(bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:74: Bamboo.SMTPAdapter.handle_response/1
(elixir) lib/task/supervised.ex:94: Task.Supervised.do_apply/2
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<0.115485522/0 in Bamboo.TaskSupervisorStrategy.deliver_later/3>
Args: []
Can you help me, I do not know what I'm missing?
I need to update my sendgrid integration to authenticate with an API key but it seems this lib does not support that...?
As described in rcf3461 smtp supports delivery status notifications. It would be nice to have a way to check on DSNs for an email to see if it failed to deliver
Changes introduced by #37
Are there any plans to support attachments for the Bamboo adapter now that Bamboo has the ability to send them?
So I was just wondering why do you guys create the email content from scratch? Why not use something like https://github.com/Vagabond/gen_smtp ?
The thing is, it'll get quite complicated to assemble more advanced emails with attachments, multipart etc.
We need that at, and at some point it will be an issue to us. Can I do some work to port code from, say https://github.com/swoosh/swoosh/blob/master/lib/swoosh/adapters/smtp.ex to your project?
Otherwise I'll have to set up bamboo_smtp_2
project and I would hate maintaining it :P
This is standard limitation according to RFC5322.
The solution is to use Content-Transfer-Encoding: Quoted-printable but Bamboo used together with Phoenix has the following problem:
Hi guys, I got this error with gen_smtp :(
** (exit) an exception was raised: ** (UndefinedFunctionError) function :socket.connect/5 is undefined or private (gen_smtp) :socket.connect(:tcp, 'email-smtp.us-east-1.amazonaws.com', 587, [:binary, {:packet, :line}, {:keepalive, true}, {:active, false}], 5000) (gen_smtp) /.../deps/gen_smtp/src/gen_smtp_client.erl:533: :gen_smtp_client.connect/2 (gen_smtp) /.../deps/gen_smtp/src/gen_smtp_client.erl:198: :gen_smtp_client.do_smtp_session/3 (gen_smtp) /.../deps/gen_smtp/src/gen_smtp_client.erl:143: :gen_smtp_client.try_smtp_sessions/4 (bamboo_smtp) lib/bamboo/adapters/smtp_adapter.ex:77: Bamboo.SMTPAdapter.deliver/2 (bamboo) lib/bamboo/mailer.ex:123: Bamboo.Mailer.deliver_now/3
I am attempting to send an email to an address like [email protected] and somewhere in the process it's getting truncated to [email protected]
I believe it's truncating the part after the period to 4 characters but couldn't track down where that was occurring in this library, Bamboo, or Mailman. Any help would be greatly appreciated!
Thanks!
I am currently getting the following error on travis ci {:network_failure, "[secure]", {:error, :timeout}}
.
Below is my config...
config :bep, Bep.Mailer,
adapter: Bamboo.SMTPAdapter,
server: System.get_env("SES_SERVER"),
port: 25,
username: System.get_env("SMTP_USERNAME"),
password: System.get_env("SMTP_PASSWORD"),
tls: :always,
ssl: false,
retries: 1
And the full error is...
** (Bamboo.SMTPAdapter.SMTPError) There was a problem sending the email through SMTP.
The error is :retries_exceeded
More detail below:
{:network_failure, "[secure]", {:error, :timeout}}
I am not too sure what is causing this issue. What is really quite confusing is that the error appeared when no modifications had been made to the code. Branches that were once passing on Travis are now failing.
Everything still works locally and in production so it seems like it could be an issue with Travis but any help would be appreciated.
You have relaxed the bamboo
version specification, but version 1.5.0 still has the excessively strict version requirement.
This is my configuration of the Mailer:
config :app, App.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "email-smtp.us-east-1.amazonaws.com",
port: x, # x in [25, 465, 587]
username: "user",
password: "password",
tls: :always, # can be `:always` or `:never`
retries: 1
No matter what port I use, I get an error when trying to send an email. These are the errors for each
port:
25 -> {:permanent_failure, "email-smtp.us-east-1.amazonaws.com", "530 Authentication required\r\n"}
465 -> {:network_failure, "email-smtp.us-east-1.amazonaws.com", {:error, :closed}}
587 -> {:permanent_failure, "email-smtp.us-east-1.amazonaws.com", "530 Authentication required\r\n"}
I've already tried removing ssl: true
, as suggested in #36
Tried to send an email with our own smtp server but I always get this error
** (Bamboo.SMTPAdapter.SMTPError) There was a problem sending the email through SMTP.
The error is :retries_exceeded
More detail below:
{:network_failure, "xxx.domain.com", {:error, :timeout}}
But I am connected to the server.
I'm looking at the docs, and I see that the configuration includes both tls
and ssl
keys. Why is that? Does ssl: true
mean that it's OK to connect using encryption older than TLS 1.0?
Hello,
I'd like to know if it's possible to somehow store SMTP configuration in a database and configure bamboo_smtp
at runtime instead of specifying configuration on config file.
Thanks in advance!
Can we have a new RC release that includes the commit which addresses warning on Elixir version?
Thank you! :)
The following mail does not display content in Apple Mail. The content is displayed on Googles Gmail Web site though.
new_email(
to: "[email protected]",
from: "[email protected]",
subject: "Testing Bamboo",
html_body: "<h1>Hey</h1><p>Check out this email or else.</p>",
text_body: "# Hey\n\nCheck out this email or else."
You'll find a small project here bamboo_gmail_test that I used to send the mail. Files of interest are
config/config.exs
where Bamboo.SMTPAdapter
is defined.
lib/send_gmail.ex
where the mail creation code is defined.
Mail is send by running iex
and SendGmail.Email.welcome_email |> SendGmail.Mailer.deliver_later
I opened a ticket with Bamboo first but they refered me here: bamboo/issues/193
Hi guys! Thanks for the lib! It looks like there's a config that is being expected, transport
, on which there isn't any documentation. It also looks like the default should be coming through there but maybe it isn't?
I'm calling Bamboo.Mailer.deliver_now
directly, so that might have something to do with it?
(UndefinedFunctionError) function nil.send_blocking/2 is undefined or private
Trying to set the sender's name with this bit of code:
|> from({"John Doe", "[email protected]"})
and that gives me an error:
553 <John Doe<[email protected]> invalid email address
Apparently in gen_smtp
, we have this line that wraps the email field as such:
try_MAIL_FROM(From, Socket, Extensions) ->
% someone was bad and didn't put in the angle brackets
try_MAIL_FROM("<"++From++">", Socket, Extensions).
Locally, via mailcatcher
ruby gem I can see that the request went through just fine, but the From field is set to <John Doe<[email protected]>>
. I'm not sure if this is the correct format but maybe that's where the issue is, or maybe the bamboo_smtp is sending the wrong format?
Thanks!
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.