#!/usr/bin/perl

print "Content-Type: Text/HTML\n\n";

use CGI ':standard';
use Vpanel 1.00;
require $header;
require $accountinfo;
$domainnname = find_domain ($mainuser);

# Define the tab which appears to the front
$tab_section = $tabnum_email;

# Output the content associated with this tab
print "<body class=section-$tab_section>";

# display tabs
require $tabdisplay;

$user = param ('user');
$address = param('address');
$multidrop_address = "\@$domainname";

print_header ("Replacement of your email set up with a multidrop account");

$multidrop_exists = find_if_address_exists($multidrop_address);

if ( ( $address_exists != 0 ) || ( $multidrop_exists == 1 ) )
{
        print "Sorry, but this multidrop appears to already exist.<BR><BR>";
        print_support_contact_information();
} else {

	print qq!
		Thank you for your request to replace your entire email set up with a multidrop email account. 
		All emails sent to anyone \@$domainname	will from now on be sent to
	!;

	open ( OVERWRITE, ">>$overwrite_email_with_multidrop_file");

	if ( $address eq "none" )
	{
		print OVERWRITE "$multidrop_address,$mainuser\n";
		print " the user $user.";
	} else {
		print OVERWRITE "$multidrop_address,$address\n";
		print " the email address $address.";
	}	
	close (OVERWRITE);
	show_time_to_change();
}

require $footer;
