![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
|
|||||
|
Коротко и ясно!
__________________
With the best regards Alex V. White |
|
|||||
|
Регистрация: Nov 2002
Сообщений: 18
|
Я нашел один "англоязычный" скрипт для отпрвавки почты без вызова почтового клиента. Настроил, работает. Беда только в том что он берет сообщения только с полей от кого -"subject" и откуда "email". Как настроить его для сбора информации с других полей что бы отправлять само сообщение непонятно. Я имею ввиду приходят пустые письма в которых только указывается от кого и от откуда.
Может подскажите как добавить обработку и других полей? Вот скрипт: #!/usr/bin/perl ####################################################### #-----------------------------------------------------# # BS Form (version 1.3) # #-----------------------------------------------------# # Copyright 1999 Brian Stanback All Rights Reserved. # # # # Email: webmaster@stanback.net # # Webpage: http://www.stanback.net # #-----------------------------------------------------# # You are free to change this script in any way you # # want, as long as the copyright and this message # # remain intact. I will not be held responsable for # # any damage this script may cause. If you use this # # script I would appreciate a link back to my site # # (stanback.net). Enjoy! :-) # ####################################################### # This is a simple form which will take in a users name, # email, phone number, message, and message subject and # email it to you. It can read from a file and automatically # send it to the user. Script does not require SSI. ######################### # Declare the variables # ######################### $mailprogram = "/usr/sbin/sendmail"; # Sendmail $myemail = 'logo17@yandex.ru'; @required = ('email','subject'); # Required Fields $auto_response = "False"; # Do you want an autoresponse? # True = yes and False = no $auto_response_file = "response.txt"; # File with the message you want to give the user # automatically when (s)he sends the form. ##################################################### # You don't need to change anything below this line # ##################################################### # Parse the form read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\;//g; $value =~ s/\|//g; $value =~ s/\</>/g; $value =~ s/\>/</g; $FORM{$name} = $value; } $FORM{'email'} =~ s/^([^ ]+) (.*)/$1/g; # Check for all required fields foreach $check(@required) { unless ($FORM{$check}) { print "Content-type: text/html\n\n"; print "<html>\n<head>\n<title>Missing Information</title>\n</head>\n"; print "<body bgcolor=\"#000000\" text=\"#FFFFFF\">\n<div align=\"center\">\n"; print "<h2>Missing Information</h2><hr>\n"; print "<STRONG>Sorry, please fill out the $check field. Go back and try again.</STRONG>\n</div>\n"; print "</body>\n</html>\n"; exit; } } # Check the users email if ($FORM{'myemail'}) { unless ($FORM{'myemail'} =~ /\w+@\w+.\w+/) { print "Content-type: text/html\n\n"; print "<html>\n<head>\n<title>Bad E-mail</title>\n</head>\n"; print "<body bgcolor=\"#000000\" text=\"#FFFFFF\">\n<div align=\"center\">\n"; print "<h2>Bad E-mail</h2><hr>\n<STRONG>The e-mail address that the user of this \n"; print "script entered is invalid. Please contact them.</strong>\n"; print "</div>\n</body>\n</html>"; exit; } } # Check the senders email if ($FORM{'email'}) { unless ($FORM{'email'} =~ /\w+@\w+.\w+/) { print "Content-type: text/html\n\n"; print "<html>\n<head>\n<title>Bad E-mail</title>\n</head>\n"; print "<body bgcolor=\"#000000\" text=\"#FFFFFF\">\n<div align=\"center\">\n"; print "<h2>Bad E-mail</h2><hr>\n<STRONG>The e-mail address that you've\n"; print "entered, $FORM{'email'}, is invalid. How would I ever contact you? Go back and try again.</STRONG>\n"; print "</div>\n</body>\n</html>"; exit; } } # Send me the email open (MAIL,"|$mailprogram -t"); print MAIL "To: $myemail\n"; print MAIL "From: <$FORM{'email'}> $FORM{'name'}\n"; print MAIL "Subject: $FORM{'subject'}\n\n"; foreach $line ($FORM{'info'}) { print MAIL "$line"; } print MAIL "\n\n--\n$FORM{'name'}\n"; print MAIL "$FORM{'phone'}"; close MAIL; # Send user an autoresponse. if ($auto_response =~ /True/i && $FORM{'email'}) { open (MAIL,"|$mailprogram -t"); print MAIL "To: $FORM{'name'} <$FORM{'email'}>\n"; print MAIL "From: $myemail\n"; print MAIL "Subject: Re: $FORM{'subject'}\n\n"; print MAIL "This is an autoresponse notifying you that your email has indeed been received. I shall be contacting you shotly.\n\n"; foreach $line ($FORM{'info'}) { print MAIL ">$line"; } close MAIL; } # Print thank you message to the user. print "Content-type: text/html\n\n"; print "<html>\n<head>\n<title>Thank you!</title>\n</head>\n"; print "<body bgcolor=\"#000000\" text=\"#FFFFFF\">\n"; print "<div align=\"center\"><h2>Thank you!</h2><hr>\n<STRONG>I have received your information \n"; print "and will get back to you asap.\n"; if ($auto_response =~ /True/i && $FORM{'email'}) { print "You should receive an autoresponse shortly.<p>\n"; } print "</STRONG></div>\n</body>\n</html>"; Скрипт могу выслать на мыло. Спасибо. |
![]() |
Часовой пояс GMT +4, время: 02:31. |
|
|
« Предыдущая тема | Следующая тема » |
|
|