Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

MIME::Lite (format time)

by softworkz (Monk)
on Mar 10, 2005 at 16:09 UTC ( #438312=perlquestion: print w/replies, xml ) Need Help??
softworkz has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks, I have this email program that works fine with sending the attachments, but I can't seem to figure out how to modify the time? The time is exactly 5 hours ahead of actual time it was sent. Can someone point me in the right direction? Thanks!
#!/usr/bin/perl -w use strict; use MIME::Lite; &Send_EMail; sub Send_EMail{ my $Dir = "D:\\SomeDir"; # Open the folder unless(opendir(DIR, $Dir)) { # print "Cannot open folder $folder!\n"; exit; } # Read the folder, ignoring special entries "." and ".." my @Files = grep (!/^\.\.?$/, readdir(DIR)); closedir(DIR); my $msg = new MIME::Lite From =>'them@somewhere', To =>'you@somewhere', Subject =>'Report', Type =>'multipart/mixed'; attach $msg Type =>'TEXT', Data =>"DO NOT REPLY TO THIS MESSAGE\n"; my $File = $_; foreach $File(@Files) { attach $msg Type =>'image/gif', Path =>"$Dir\\$File", Filename =>"$File"; } MIME::Lite->send( 'smtp', '', Tim +eout => 20 ); $msg->send || die "Cannot send message: $!"; }

Replies are listed 'Best First'.
Re: MIME::Lite (format time)
by moot (Chaplain) on Mar 10, 2005 at 16:24 UTC
    Perhaps you should look at the timezone on the SMTP server.
      I figured it out. I made an adjustment in the module, see the below code.
      ### Datestamp if desired: # ------------------------------------------------ my $Sec; my $Min; my $Hour; my $MDay; my $Mon; my $Year; my $WDay; my $YDay; my $IsDst; ($Sec,$Min,$Hour,$MDay,$Mon,$Year,$WDay,$YDay,$IsDst)=localtime(time); + # ------------------------------------------------ my $ds_wanted = $params{Datestamp}; my $ds_defaulted = ($is_top and !exists($params{Datestamp})); if (($ds_wanted or $ds_defaulted) and !exists($params{Date})) { my ($u_wdy, $u_mon, $u_mdy, $u_time, $u_y4) = split /\s+/, gmtime().""; ### should be non-locale-dependent $u_time = "$Hour:$Min:$Sec"; # now fix the time my $date = "$u_wdy, $u_mdy $u_mon $u_y4 $u_time UT"; $self->add("date", $date); }
        Well, ok, but it strikes me that's a lot of work when all you have to do is adjust the timezone on the SMTP server. You'll probably find it's set to GMT/ UTC, where your client machine is set to GMT+5/ EST or something similar.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://438312]
Approved by Joost
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-12-19 03:32 GMT
Find Nodes?
    Voting Booth?
    How many stories does it take before you've heard them all?

    Results (83 votes). Check out past polls.