how to set time

P

Peter

Hello All,
I'm a newbie and busy with a mailform.

This mailform sent autoresponse mail.
My question is if it possible to sent the autoresponse mail one or two days later after receiving the mail.


I think it has to be change in this piece of code ?



$offset = @_;
$offset=$offset*86400;

($sec, $min, $hour, $dayofmonth, $mon, $year, $weekday, $dayofyear, $IsDST) = localtime(time + $offset);
$year = $year + 1900;
@months = ("JA", "FB", "MR", "AP", "MY", "JN", "JL", "AG", "SP", "Oc", "NV", "DE");
$monthname = $months[$mon];
@monthsnum = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
$monthnamenum = $monthsnum[$mon];

@monthsactual = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$monthnameactual = $monthsactual[$mon];


@days = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
$dayname = $days[$weekday-1];

${'monthname'} = "$monthname";
${'monthnamenum'} = "$monthnamenum";
${'dayofmonth'} = "$dayofmonth";


if ($hour > 12){
$hourplus=$hour;
$newhour = ($hourplus-12);
$nightday = "PM";
}else{
$newhour=$hour;
$nightday = "AM";
}


if ($min <= 9){
$newmin = "0$min";
}else{
$newmin = "$min";
}

${'hour'}=$newhour;
 
A

A. Sinan Unur

I'm a newbie and busy with a mailform.

This mailform sent autoresponse mail.
My question is if it possible to sent the autoresponse mail one or two
days later after receiving the mail.

Yes, but that has nothing to do with the code you posted below.
I think it has to be change in this piece of code ?

Is that a question or statement?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Please post plain text only.

Sinan
 
P

Peter

Hello Sinan,

Yes it is a question because I really don't know how to change it.
I want to sent the autoresponse 1 or 2 days later.

Hereby I sent the send mail script.



sub sdsmail {


if ($send_email_results eq "1") {

open(MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $MAIN_mail_send\n";
if ($mail_ccto){
print MAIL "Cc: $mail_ccto\n";
}
print MAIL "From: $formdata{'email'}\n";
print MAIL "Subject: $formdata{'subject'}\n";
print MAIL "The form below was submited by $formdata{'email'} form Ip
address: $ENV{'REMOTE_ADDR'} on $monthnameactual $dayofmonth, $year at
$newhour:$newmin $nightday \n";
print MAIL
"-------------------------------------------------------------------------\n\n";


if (! $formdata{'sort'}) {


for ($indexval = 0; $indexval < @formvalue; $indexval++) {
${'myname'} = $formname[$indexval];
${'myvalue'} = $formvalue[$indexval];


if (${'myname'} eq "reply_subject"|| ${'myname'} eq "subject" ||
${'myname'} eq "sendreply" || ${'myname'} eq "required" || ${'myname'} eq
"success_page" || ${'myname'} eq "message_format" || ${'myname'} eq
"text_qualifier" || ${'myname'} eq "datafile" || ${'myname'} eq "outputfile"
|| ${'myname'} eq "sort" || ${'myname'} eq "data_format" || ${'myname'} eq
"cc_to" || ${'myname'} eq "send_to" || ${'myname'} eq "plain_mesfile" ||
${'myname'} eq "html_mesfile" || ${'myname'} eq "error_page" || ${'myname'}
eq "required_desc"){
$dontrun = "1";
}else{
$dontrun = "";
}

## CHECK PRINT BLANK FIELDS ##
if ($PRNT_blankfields eq "2" && ! ${'myvalue'}) {
$dontrun = "1";
}

if (! $dontrun){
print MAIL "${'myname'}: ${'myvalue'} \n\n";
}
}

}else{ ##ELSE IF NO SORT FIELD ##

for ($numsort = 0; $numsort < @sortfields; $numsort++) {
$sfield = $sortfields[$numsort];
${'sfieldvalue'} = $formdata{"$sfield"};
${'sfield'} = "$sfield";

## CHECK PRINT BLANK FIELDS ##
if ($PRNT_blankfields eq "2" && ! ${'myvalue'}) {
}else{

print MAIL "${'sfield'}: ${'sfieldvalue'} \n\n";

} ## END CHECK PRINT BLANK FIELDS ##

}

} ## END ELSE IF SORT FIELD ##

close MAIL;

} ## END IF SEND_EMAIL_RESULTS##

if ($formdata{'sendreply'} eq "1"){



use MIME::Lite;
MIME::Lite->send("sendmail", "$mailprog -t -oi -oem");



$msg = MIME::Lite->new(
From => $mail_sendto,
To => $formdata{'email'},
Subject => $reply_subject,
Type => $email_format,
Data => $mime_body,
"X-Arpidentifier:" => 12345

);

########################################
## USE ATTACHEMENT ##
########################################

if ($send_attachement eq "1"){

$msg->attach(Type => $att_content_type,
Encoding => $att_format->[1],
Path => $att_path,
Filename => $attachment_nm
);

}


######################################
$msg->send;
}

}

return 1;
 
G

Gunnar Hjalmarsson

Peter said:
This mailform sent autoresponse mail.
My question is if it possible to sent the autoresponse mail one or two
days later after receiving the mail.
Yes.

I think it has to be change in this piece of code ?

<code snipped>

No.

To schedule the execution of code to a point of time in the future, you
need a daemon. Check out

perldoc -q daemon
 
A

A. Sinan Unur

Yes it is a question

What is a question? Oh, you are top-posting, please do not do that.
Please take this opportunity to read the posting guidelines for this
group.
because I really don't know how to change it.
I want to sent the autoresponse 1 or 2 days later.

Hereby I sent the send mail script.

I think you are failing to realize the fundamental issue here. What is
the point of expecting this script to wait for 172800 seconds to send
the message?

Instead, put the information in a table, have some kind of periodic task
check the table for emails that need to be sent, and then send them.

The script you posted is so badly written that just reading it is
irritating.

You are missing:

use strict;
use warnings;

use CGI;
sub sdsmail {
if ($send_email_results eq "1") {

Please make some effort to format the code you are posting properly.
That will make your readers' lives easier and enable to them to help you
more effectively.

Where did $send_email_results come from?

You would normally check a boolean by just using the simple

if($send_email_results) {

}

No need for silly string comparisons.
open(MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $MAIN_mail_send\n";
if ($mail_ccto){
print MAIL "Cc: $mail_ccto\n";
}

It looks like you are not using a hash when you should be:

my %main = (
mail_to => '(e-mail address removed)',
mail_cc => '(e-mail address removed)',
);

etc.
print MAIL "From: $formdata{'email'}\n";
print MAIL "Subject: $formdata{'subject'}\n";

It looks like you are using a home-made CGI parameter parsing thingie
rather than CGI.pm. Most likely not a good idea.
print MAIL "The form below was submited by $formdata{'email'} form Ip
address: $ENV{'REMOTE_ADDR'} on $monthnameactual $dayofmonth, $year at
$newhour:$newmin $nightday \n";

Whatever ...

for ($indexval = 0; $indexval < @formvalue; $indexval++) {
${'myname'} = $formname[$indexval];
${'myvalue'} = $formvalue[$indexval];

Please don't do this.

perldoc -q "variable name"

I cannot even get myself to look at the code.
if (${'myname'} eq "reply_subject"|| ${'myname'} eq "subject" ||
${'myname'} eq "sendreply" || ${'myname'} eq "required" || ${'myname'}

I think a visit to said:
if (! $dontrun){

unless( $dontrun ) {
use MIME::Lite;
MIME::Lite->send("sendmail", "$mailprog -t -oi -oem");

WTF!!!? You just opened a pipe to sendmail above. *Now* it occurs to you
to use MIME::Lite? Why not just use MIME::Lite and be done with it?

Sinan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top