diff --git a/modules/websubmit/lib/functions/Mail_Submitter.py b/modules/websubmit/lib/functions/Mail_Submitter.py index a316def6b..5be14a04d 100644 --- a/modules/websubmit/lib/functions/Mail_Submitter.py +++ b/modules/websubmit/lib/functions/Mail_Submitter.py @@ -1,94 +1,104 @@ ## $Id$ ## This file is part of the CERN Document Server Software (CDSware). ## Copyright (C) 2002, 2003, 2004, 2005 CERN. ## ## The CDSware is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## The CDSware is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDSware; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## ## Name: Mail_Submitter.py ## Description: function Mail_Submitter ## This function sends a confirmation email to the submitter ## of the document ## Author: T.Baron ## ## PARAMETERS: authorfile: name of the file containing the author ## titleFile: name of the file containing the title ## emailFile: name of the file containing the email ## status: one of "ADDED" (the document has been integrated ## into the database) or "APPROVAL" (an email has ## been sent to a referee - simple approval) ## edsrn: name of the file containing the reference ## newrnin: name of the file containing the 2nd reference ## (if any) ## OUTPUT: HTML ## +from cdsware.websubmit_config import cfg_websubmit_copy_mails_to_admin + execfile("%s/cdsware/websubmit_functions/mail.py" % pylibdir) def Mail_Submitter (parameters,curdir,form): FROMADDR = '%s Submission Engine <%s>' % (cdsname,supportemail) # retrieve report number edsrn = parameters['edsrn'] newrnin = parameters['newrnin'] fp = open("%s/%s" % (curdir,edsrn),"r") rn = fp.read() fp.close() rn = re.sub("[\n\r]+","",rn) if newrnin != "" and os.path.exists("%s/%s" % (curdir,newrnin)): fp = open("%s/%s" % (curdir,newrnin),"r") additional_rn = read() fp.close() additional_rn = re.sub("[\n\r]+","",additional_rn) fullrn = "%s and %s" % (additional_rn,rn) else: fullrn = rn fullrn = fullrn.replace("\n"," ") # The title is read from the file specified by 'titlefile' try: fp = open("%s/%s" % (curdir,parameters['titleFile']),"r") m_title = fp.read().replace("\n"," ") fp.close() except: m_title = "-" # The name of the author is read from the file specified by 'authorfile' try: fp = open("%s/%s" % (curdir,parameters['authorfile']),"r") m_author = fp.read().replace("\n"," ") fp.close() except: m_author = "-" # The submitters email address is read from the file specified by 'emailFile' try: fp = open("%s/%s" % (curdir,parameters['emailFile']),"r") m_recipient = fp.read().replace ("\n"," ") fp.close() except: m_recipient = "" # create email body email_txt = "The document %s\nTitle: %s\nAuthor(s): %s\n\nhas been correctly received\n\n" % (fullrn,m_title,m_author) # The user is either informed that the document has been added to the database, or sent for approval if parameters['status'] == "APPROVAL": email_txt = email_txt + "An email has been sent to the referee. You will be warned by email as soon as the referee takes his/her decision regarding your document.\n\n" elif parameters['status'] == "ADDED": email_txt = email_txt + "It will be soon added to our Document Server.\n\nOnce inserted, you will be able to check the bibliographic information and the quality of the electronic documents at this URL:\n<%s/search.py?recid=%s>\nIf you detect an error please let us know by sending an email to %s. \n\n" % (htdocsurl,sysno,supportemail) email_txt = email_txt + "Thank you for using %s Submission Interface.\n" % cdsname + # send the mail - body = forge_email(FROMADDR,m_recipient,adminemail,"%s: Document Received" % fullrn,email_txt) - tostring = "%s,%s" % (m_recipient,adminemail) - tolist = re.split(",",tostring) - send_email(FROMADDR,tolist,body,0) + tostring = m_recipient.strip() + if cfg_websubmit_copy_mails_to_admin: + # Copy mail to admins: + if len(tostring) > 0: + tostring += ",%s" % (adminemail,) + else: + tostring = adminemail + body = forge_email(FROMADDR,m_recipient,"","%s: Document Received" % fullrn,email_txt) + tolist = tostring.split(",") + if len(tolist[0]) > 0: + send_email(FROMADDR,tolist,body,0) return ""