in reply to Re: send mail with STARTTLS
in thread send mail with STARTTLS

You are not sending a Date header at all in your code, but it seems gmx wants one.

Replies are listed 'Best First'.
Re^3: send mail with STARTTLS
by Anonymous Monk on Dec 15, 2025 at 13:48 UTC

    I tried this:

    use strict; use warnings; use Net::SMTP ; my $afz = 'anyone@gmx.com'; my $pass = '*****'; my $ontv = 'any@gmail.com'; my $date = localtime(); my $mailer = Net::SMTP->new( 'mail.gmx.com', Hello => 'mail.gmx.com', Port => 587, Debug => 1 ); $mailer->starttls(); $mailer->auth($afz, $pass); $mailer->mail($afz); $mailer->recipient($ontv); $mailer->data(); $mailer->datasend("From: $afz"); $mailer->datasend("To: $ontv"); $mailer->datasend("Subject: testmail"); $mailer->datasend("Date: $date"); $mailer->datasend("\n"); $mailer->datasend("Hallo daar."); $mailer->dataend(); $mailer->quit
    But it does not change anything. I also tried giving just the date and not the time but nothing. Maybe i'll try sending from my gmail account to my gmx account but that is a pour solution if it works at all.

      Try with newlines at the end of each datasend that doesn't have and end with a dataend call, not a dot? That's what the module example shows.

        Yes now it is working, thank you very much. Sorry for not paying attention, I found an example on the internet but it wasn't correct. The module documentation is correct indeed and everything is working just fine now.

      Are you sure that [func://localtime]() or giving "just the date" are things that will supply a well-formatted Date header?

      You most likely want something like DateTime::Format::Mail. At least your value should look something like Sat, 29 Mar 2003 22:11:18 -0800.

        As a funny sidenote, depending on the Date library used, just make sure the weekday name calculation is correct. Many, many, many years ago i once ran into that exact problem. Sudenly, my mails started getting rejected by some server, leading me on a long bug hunt... until i found a leap year bug that messed up weekday names...

        PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
        Also check out my sisters artwork and my weekly webcomics
      use Time::Piece; my $date = localtime (time)->strftime ('%a, %d %b %Y %T %z');

      works for me. YMMV.


      🦛