Email Receiving POP3/IMAP

I am currently trying to connect to an in-house email server to download one email and process it.
I looked all around for usable packages for either POP3 or IMAP. I could not find any packages for IMAP neither for Elixir nor for Erlang that seem usable.
Is downloading an email too simple for a package or why is there no support so far for such an important functionality?

The only package in Elixir that addresses POP3 seems to be https://github.com/nico-amsterdam/pop3mail. I tried using it from within an Elixir project and I tried to call it via CLI:
mix run -e 'Pop3mail.CLI.main(["--username=<username>", "--password=<password>", "--max=10", "--server=example.com", "--port=110"])'

I tried several server configurations either with pop in the server address or without. With the above config, which I took from the description on Github, I always get a [error] connect_failed

Does anyone have an idea what the issue at hand could be assuming the credentials as well as the server address and port are correct (I checked them via telnet).

I am grateful for any suggestions.

3 Likes

Posting things here always helps your (or rather my) own awareness. One of the issues is that the mailserver does not use SSL…

Otherwise I would not be able to connect via telnet, obviously! So now the way to access the server within Elixir is:

def download_one_message do
    Pop3mail.download(%{"username" => @user, "password" => @pw, "server" => @server, "max" => 1, "port" => 110, "ssl" => false})
end

Now I get a different error, but this seems to be server specific and not due to the connection or the package. I now get {:error, ' login must use full email address\r\n'}. I will check with the admis what’s amiss, thank you anyways for this great forum!

2 Likes

Sounds like you need username to be the full email address which could be either something like name@domain.com or, depending on how your server is set up (prob via saslauthd) name.domainaccountname where domainaccountname is the name of the linux user relating to that email/domain.

1 Like

Thanks for the fast reply. I do actually use name@example.com notation:

def download_one_message do
   Pop3mail.download(%{"username" => "name@example.com", "password" => "wicket_strong_pw", "server" => "server.example.com", "max" => 1, "port" => 110, "ssl" => false})
end
2 Likes

Please do not use any email address or domain that is not owned by you. It might increase spam for that given address. If you do not want to waste one of your own please use example.com for the domain name. It does exist exactly for this purpose.

2 Likes

The logs on the mail server imply, that part of the email address entered is removed somewhere. It seems like everything after including the “@” sign is missing. Any idea on why and how that happens? Do I need to escape some characters or use special quotation marks? To me it seems to be an issue with the epop implementation.

EDIT: I simply appended “@example” to the username and everything works fine:

def download_one_message do
    Pop3mail.download(%{"username" => "name@example.com@example.com", "password" => "wicket_strong_pw", "server" => "server.example.com", "max" => 1, "port" => 110, "ssl" => false})
end

I also filed an issue in order to request it be marked in the documentation that the username is shortened.

2 Likes