karastojko / mailio

mailio is a cross platform C++ library for MIME format and SMTP, POP3 and IMAP protocols. It is based on standard C++ 17 and Boost library.
Other
374 stars 98 forks source link

None flag not working #115

Closed ercolesptr closed 1 year ago

ercolesptr commented 1 year ago

I have build the project with mingw and know that it is working because I was able to send email via a server needing starttls. Now however I need to send an email via an smtp server which does not require any login or security protocol. I tried to send the email using NONE instead of starttls and setting the login and password to "". However it is giving me an error cannot start tls. Why is the None flag not working?

karastojko commented 1 year ago

Are you using smtp or smtps class? To which port are you connecting?

ercolesptr commented 1 year ago

I am using port 25 as the server has no authentication and does not need password or login credentials. Also when I tried smtp instead of smtps it does not compile. Can you give me an example how to use smtp?

karastojko commented 1 year ago

You have to use smtp::auth_method_t with smtp, something like:

smtp conn("smtp.alepho.com", 587);
conn.authenticate("user@mailio.dev", "", smtp::auth_method_t::LOGIN);

Does it solve your problem?

ercolesptr commented 1 year ago

The port has to be 25 as this server uses the default smtp port of 25.

When I used smtp instead of smtps it gave me an error. Do I have to include other headers besides message and smtp headers?

karastojko commented 1 year ago

It shouldn't. Take a look of the example smtp_utf8_qp_msg.cpp, it uses SMTP not SMTPS. Does this example compile in your setup?

ercolesptr commented 1 year ago

When I use smtp instead of smtps it is giving me an error:

smtp was not declared in this scope

karastojko commented 1 year ago

Can you please copy here the minimum reproducible example?

ercolesptr commented 1 year ago

I found the cause of the error. I had to amend this as well:

using mailio::smtp; instead of using mailio::smtps;

ercolesptr commented 1 year ago

It worked perfectly now, I used port 25 and "" for both login and password and email was sent and recived.