#!/usr/bin/perl # You may need to change this path to /usr/local/bin/perl $mailprog = "/usr/sbin/sendmail"; %OPTS = @ARGV; #************************************************************** # # Script to send automatic email upon account creation: PWSpostwwwacct2 V2.5 # # Written by: # Premier Website Solutions - http://www.premierwebsitesolutions.com # Created - in 2003 (V1.0) # Modified - March 2, 2004 (V2.0) # - extracted auto email part from our own postwwwacct script # - altered to be more usable by others # - added instructions for other users # Modified - March 4, 2004 (V2.01) # - added variable to specify who the message is from # Modified - March 11, 2004 (V2.1) # - made it easy to use when another postwwwacct script is also being used # Modified - April 13, 2004 (V2.11) # - added note about using special characters in email message # Modified - April 26, 2004 (V2.12) # - modified email template # Modified - July 18, 2006 (V2.2) # - fixed minor error when no email is entered in WHM # Last Modified - February 19, 2009 (V2.5) # - modified to work with cPanel changes using %OPTS instead of @ARGV # # To use this script, just set a few variables below, modify the email message to # your desire, and upload this file to the /scripts directory on your server, renamed # to postwwwacct and made executable. # # Every time an account is created in WHM, this script is automatically called to # do it's job. Variables are passed to it from WHM's wwwacct script and some of # those variable are used to customize the email message. # # Here are the variables that are passed to this script: # $OPTS{'user'} (string) - User name of the account. Ex: user # $OPTS{'domain'} (string) - Domain name. Ex: domain.tld # $OPTS{'plan'} (string) - Package to use for account creation. Ex: reseller_gold # $OPTS{'quota'} (integer) - Disk space quota in MB. (0-999999, 0 is unlimited) # $OPTS{'pass'} (string) - Password to access cPanel. Ex: p@ss!w0rd$123 # $OPTS{'useip'} (string) - Whether or not the domain has a dedicated IP address. (y = Yes, n = No) # $OPTS{'hascgi'} (string) - Whether or not the domain has cgi access. (y = Yes, n = No) # $OPTS{'installfp'} (string) - Whether or not the domain has FrontPage extensions installed. (y = Yes, n = No) # $OPTS{'hasshell'} (string) - Whether or not the domain has shell / ssh access. (y = Yes, n = No) # $OPTS{'contactemail'} (string) - Contact email address for the account. Ex: user@otherdomain.tld # $OPTS{'cpmod'} (string) - cPanel theme name. Ex: x3 # $OPTS{'maxftp'} (string) - Maximum number of FTP accounts the user can create. (0-999999 | unlimited, null | 0 is unlimited) # $OPTS{'maxsql'} (string) - Maximum number of SQL databases the user can create. (0-999999 | unlimited, null | 0 is unlimited) # $OPTS{'maxpop'} (string) - Maximum number of email accounts the user can create. (0-999999 | unlimited, null | 0 is unlimited) # $OPTS{'maxlst'} (string) - Maximum number of mailing lists the user can create. (0-999999 | unlimited, null | 0 is unlimited) # $OPTS{'maxsub'} (string) - Maximum number of subdomains the user can create. (0-999999 | unlimited, null | 0 is unlimited) # $OPTS{'maxpark'} (string) - Maximum number of parked domains the user can create. (0-999999 | unlimited, null | 0 is unlimited) # $OPTS{'maxaddon'} (string) - Maximum number of addon domains the user can create. (0-999999 | unlimited, null | 0 is unlimited) # $OPTS{'bwlimit'} (string) - Bandiwdth limit in MB. (0-999999, 0 is unlimited) # $OPTS{'useregns'} (boolean) - Use the registered nameservers for the domain instead of the server configured ones. (1 = Yes, 0 = No) # $OPTS{'owner'} (string) - Owner of the account. # # Registered users of this script will be notified of any future updates. # If you registered this copy with us, put your email here for future reference. # This copy is registered to: # #************************************************************** # To send yourself a copy of the email, put your email address here. # If you use spamassassin, you should include a name, like this: # $email = 'me '; $email = ''; # This is the email address that will be the sender of the automatic email. # You may prefer to put your own email address here. ;-) $from = 'Mike '; # If you prefer to send the email in html format, change the next line to Y. $usehtml = "N"; # Change this subject line to whatever you prefer $subject = "Your new account for $OPTS{'domain'} is ready"; # This is just to convert the bandwidth from MB to GB for the email message. # Calculations like this must be done before the message string variables are specified. $gb = $OPTS{'bwlimit'}/1024; $gb = $gb . "GB"; # This is the message that will be sent if you choose to use html. You can modify # this message any way you like. All the $OPTS{'xxxx'} variables are replaced with the # appropriate value. See the variables uses above. Do not touch the first or last # line here. If you use any of the following characters, @ % $ or ", you will need to # escape them by putting a \ in front of them, like: \@ \% \$ or \" $html_message = " Here are the details of your new account:
\n Domain Name: $OPTS{'domain'}
\n Username: $OPTS{'user'}
\n Password: not sent for safety
\n Package: $OPTS{'plan'}
\n - space: $OPTS{'quota'}MB
\n - bandwidth: $OPTS{'bwlimit'}MB ($gb)
\n - theme: $OPTS{'cpmod'}
\n - Dedicated IP ($OPTS{'useip'})
\n - POP accounts: max - $OPTS{'maxpop'}
\n - mailing lists: max - $OPTS{'maxlst'}
\n - MySql databases: max - $OPTS{'maxsql'}
\n - subdomains: max - $OPTS{'maxsub'}
\n
\n Shell Access: $OPTS{'hasshell'}
\n
\n Contact Email: $OPTS{'contactemail'}
\n Please keep this up to date.
\n
\n
\n "; # This is the message that will be sent if you choose to use plain text. You can # modify this message any way you like. All the $OPTS{'xxxx'} variables are replaced # with the appropriate value. See the variables uses above. Do not touch the first # or last line here. If you use any of the following characters, @ $ or ", you will # need to escape them by putting a \ in front of them, like: \@ \$ or \" $text_message = " Here are the details of your new account: Domain Name: $OPTS{'domain'} Username: $OPTS{'user'} Password: not sent for safety Package: $OPTS{'plan'} - space: $OPTS{'quota'}MB - bandwidth: $OPTS{'bwlimit'}MB ($gb) - theme: $OPTS{'cpmod'} - Dedicated IP ($OPTS{'useip'}) - POP accounts: max - $OPTS{'maxpop'} - mailing lists: max - $OPTS{'maxlst'} - MySql databases: max - $OPTS{'maxsql'} - subdomains: max - $OPTS{'maxsub'} Shell Access: $OPTS{'hasshell'} Contact Email: $OPTS{'contactemail'} Please keep this up to date. "; #------------------------------------------------------------------- #------------------------------------------------------------------- # UNLESS YOU KNOW CGI, DO NOT EDIT ANYTHING BELOW HERE # Feel free to study the code, but alterations are at your own risk #------------------------------------------------------------------- #------------------------------------------------------------------- if ($OPTS{'contactemail'} eq "") { $client_email = $OPTS{'user'} . "\@" . $OPTS{'domain'}; $emailnote = "$client_email which is username\@domain.com because no email was provided in WHM"; } else { $client_email = $OPTS{'contactemail'}; $emailnote = "$OPTS{'contactemail'} which was provided in WHM"; } print "\nSending email to client...\n"; if ($usehtml eq "Y") { &send_mail_html; } else { &send_mail_txt; } print "\nEmail has been sent to client at $emailnote.\n"; if ($email ne "") { $email =~ s//>/g; print "A copy was also sent to $email.\n"; } if (-e "/scripts/postwwwacct2") { print "\nSending variables to postwwwacct2.\n"; system("/scripts/postwwwacct2",@ARGV); } exit; sub send_mail_html { print "\nsending mail...\n"; # Open The Mail Program open(MAIL,"|$mailprog -t"); print MAIL "Content-Type: text/html; charset=iso-8859-1\n"; print MAIL "To: $client_email\n"; if ($email ne "") { print MAIL "Bcc: $email\n"; } print MAIL "From: $from\n"; print MAIL "Subject: $subject\n"; print MAIL "\n"; print MAIL "$html_message\n"; print MAIL "\n\n"; close (MAIL); } sub send_mail_txt { print "\nsending mail...\n"; # Open The Mail Program open(MAIL,"|$mailprog -t"); print MAIL "To: $client_email\n"; if ($email ne "") { print MAIL "Bcc: $email\n"; } print MAIL "From: $from\n"; print MAIL "Subject: $subject\n"; print MAIL "$text_message\n"; close (MAIL); }