in reply to Net::SMTP and SSL timeout problem

SOLVED... (I think!)

I lied with the sample code in my first post: the real code had some international chars (utf8) in the Subject field, which I translated into English for you.

For an unknown reason, those chars were not a problem for a standard connection to the SMTP server, but somehow locked the connection if it was using SSL, and a timeout from the server was the result.

Also, I hacked Cmd.pm to send "\r\n.\r\n" to the SMTP server at the dataend method instead of just ".\r\n" as an email body terminator while in SSL connection and the result was an email without timeout to be sent, but the header was corrupted, and that gave me a hint. After I encoded the Subject line, all was working like a charm.

I'll continue testing and let you know what is going on... I still have to add attachments to the email, so more encoding is on the go.

Replies are listed 'Best First'.
Re^2: Net::SMTP and SSL timeout problem
by cavac (Prior) on Jun 13, 2023 at 09:22 UTC

    My guess (due to experience with my own network code) is that the module you are using is directly doing send() on the socket object in this case. send() (almost) always expects character codes below 256, otherwise you'll get a "wide character" error. Depending on the exact implementations, those characters may be dropped or an error might be raised.

    Sidenote: Proper Unicode handling depends heavily on the age of the module, the experience of the author and also partially if the author is a native english speaker living in a country that is using mostly english to communicate. Basically, if the author is using Umlauts or Emoji or Chinese/Japanese/Korean script on a daily basis, the chances Unicode is handled properly by their code is much higher.

    An easy way to really stress-test modules for their Unicode handling is Acme::Umlautify.

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Re^2: Net::SMTP and SSL timeout problem
by NERDVANA (Priest) on Jun 16, 2023 at 00:38 UTC

    I'm pretty sure all the MIME header fields must be encoded as 7-bit ascii even if you use 8-bit unicode of some sort in the body content-type. A MIME-generating module can take care of that for you. I recommend Email::MIME which lets you use header_str to specify unicode strings for headers, and then it automatically encodes them for you.