-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gen_server_client:send send_error, closed #301
Comments
I really have difficulties understanding what are you trying to do. Are you sending some email with |
It sets up a smtp server. Postfix will get mails and send them depending on the domain. The server parses the messages and rewrites the messages to route them base on a rulset. When all the processing is complete it calls gen_smtp_client.send/3 to either send a bounce or send a new rewritten message back through the postfix server. This worked fine for several years prior to the upgrade to 1.1.1. Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe] defmodule MailToJson.SmtpServer do
def start_link do
session_options = [ callbackoptions: [parse: true] ]
smtp_port = IdgonMail.config(:smtp_port)
server_config =
[
port: smtp_port,
protocol: :tcp,
domain: "example.com",
auth: :never,
tls: :never,
address: {0, 0, 0, 0}
]
:gen_smtp_server.start(MailToJson.SmtpHandler, [server_config: server_config, sessionoptions: session_options])
end
end the smtp handler def handle_DATA(from, to, data, state) do
unique_id = Base.encode16(:erlang.md5(data), case: :lower)
try do
case Idg.Email.process(data,orig_url) do
{:bounce, to, mail_pipe} ->
I.le "email bounce from: ", mail_pipe.from
{:error, "550 5.1.1 : Recipient address rejected: User unknown", state}
stuff ->
Idg.Email.send(stuff)
{:ok, unique_id, state}
end
rescue
e in IdgonNotFound ->
I.le "Idgon was not found ", {e,state}
{:error, "550 5.1.1 : Recipient address rejected: User unknown", state}
e in RuntimeError ->
I.le "something blew up ", {e,state}
reraise e, __STACKTRACE__
{:error, "111 problems on my end", state}
e ->
I.le "something blew up ", {e,state}
reraise e, __STACKTRACE__
{:error, "111 problems on my end", state}
end
end Idg.Email.send def send({:error,_,_}) do
:error
end
def send(:bounce, to, mail_pipe) do
port = 25
host = "localhost"
email = """
From: Postmaster <[email protected]>
To: #{mail_pipe.from.old.name} #{mail_pipe.from.old.address}
Subject: Bounce
email bounced
"""
client_options = [relay: host, username: "ec2-user", password: "anything", port: port]
:gen_smtp_client.send(email, client_options)
end
def send(email) do
port = 25
host = "localhost"
client_options = [relay: host, username: "mailer", password: "anything", port: port,retries: 2]
# I.lw is my logger function
callback = fn(r) -> I.lw( "callback: ", r) end
:gen_smtp_client.send(email, client_options,callback)
end |
+1; I'm getting this same error for pretty much every email received with my gen_smtp SMTP server. I'm only receiving, not sending. It doesn't seem to actually break anything since I'm receiving the email data correctly. Here's my DATA handler: def handle_DATA(from, to, data, state) do
Logger.info("Received email from #{from} with data #{data}")
%{from: from, to: hd(to), data: data}
|> EmailHandler.new()
|> Oban.insert()
{:ok, "1", state}
end and my config options: config :shroud, :mailer,
smtp_options: [
port: 1587,
sessionoptions: [
hostname: "app.shroud.email",
certfile:
"path/to/crt",
keyfile:
"path/to/key"
],
tls_options: [
# Don't verify peers (we'll forward anything we can)
verify: :verify_none,
log_level: :info
]
] If it's helpful, the full code is available here: https://gitlab.com/shroud/shroud.email/-/blob/main/lib/shroud/email/smtp_server.ex |
anyone have any ideas on this one? I'm still seeing sporadic issues. do you need a more fully flushed out example to test against? |
@jschoch I see you are using Another thing you may try to do is to suppress the |
I recently upgraded from 0.15 to 1.1.1 and i'm getting the following behavior for some emails.
i was only using send/2 before and the client was not actually sending anything. I added an implementation of handle_error in the server and added a callback to gen_smtp_client.send/3 and it will actually send but it still throws this error. Note that callback seems to have an ok result.
The text was updated successfully, but these errors were encountered: