EPrints Technical Mailing List Archive

Message: #07124


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Ask about frequency of items-under-review mailings:


Hi,

Alan is right (but I think he meant $user->get_value( 'email' ) if… ).

 

Which version of EPrints are you using?

 

If you look in EPRINTS_HOME/perl_lib/EPrints/Email.pm, do you have any references to 'to_list' or 'cc_list'?

In newer versions, the following lines handle multiple 'To' recipients, or a Cc list:

https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/Email.pm#L187-L196

https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/Email.pm#L272-L279

 

If you are using a version that has that in, you can add something like this:

my $staff_emails = qw( bob@domain.com jim@domain.com chris@domain.com );

my $cc_emails = qw( me@domain.com you@domain.com );

 

my $userMailOK = EPrints::Email::send_mail(

            session => $session,

            langid => $session->get_langid,

            to_email => 'main_email@domain.com',

            to_list => $staff_emails,

            cc_list => $cc_emails,

            subject => $session->phrase( "status_change_inbox_to_review_subject" ),

            message => $mail,

            sig => $session->html_phrase( "mail_sig" )

        );

 

 

To make a more future-proof system, you could build the to_list or cc_list dynamically using the steps I outlined below (get all editors / see if the item is 'in scope' of that editor), but that depends on how many people edit your items!

 

Cheers,

John

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Alan.Stiles
Sent: 01 February 2018 08:30
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Ask about frequency of items-under-review mailings:

 

Hi – you are trying to get_value(“email”) from a true/false value, rather than the config or the user record?

 

Try changing the line to

 

My $staff_email = $staff->get_value( “email”) if( $user->is_staff() ); 

 

I think (not checked) for multiple addresses you would need to build them into an array in the to_email => value 

 

Alan

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Ajunk Pracetio
Sent: 01 February 2018 01:22
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Ask about frequency of items-under-review mailings:

 

Hi ,

I already try your suggestion, and it works. But, when I try to use to_list and to_cc (https://wiki.eprints.org/w/API:EPrints/Email), I get error. If to_email => blabla@comain.com and I want cc to other email address let say 5 people, what function I must use?

When I try thy this method below, I get error
my $bool = $user->is_staff();
my $staff_email = $bool->get_value( "email" ); #for editor/administrator
...
to_email => $staff_email

Error from var/log :  Can't call method "get_value" without a package or object reference at (eval 663) line 20.\n
var/last_changed.timestamp has been modified since the repository config was loaded: reloading!

 

On Wed, Jan 31, 2018 at 6:01 PM, John Salter <J.Salter@leeds.ac.uk> wrote:

Hi,

That looks OK to me.

 

First, try with a hardcoded email address on this line:

to_email => #EDITOR OR ADMINISTRATOR EMAIL?,

You need to use single-quotes:

    to_email => 'the.email@domain.com',

if you use double-quotes, it might not work.

 

Let me know if that helps. If it doesn't, is there anything in the error log?

You could add something to put a message into the Apache log to check the email looks like it's been sent:

my $userMailOK = EPrints::Email::send_mail(

);

print STDERR "inbox to buffer email result: $userMailOK\n";

 

If that does work, the next question is 'how many editors do you have?'.

If it's just one (or there more than one, but they use a shared mailbox), hard-coding the email address might be OK.

If you have lots of editors, and they have different 'scopes' (you could allow one editor to process theses, another one to process journal articles), then we can do something like:

-          get all editors

-          see if the item is 'in scope' of that editor

-          email them if it is!

 

Let me know how you get on!

 

Cheers,

John

 

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Ajunk Pracetio
Sent: 31 January 2018 09:13
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Ask about frequency of items-under-review mailings:

 

Hi John,

I already try this and success. But it only for live archive, not for item that just deposited. I already try add below, but I dont know is it right or wrong.

 

$c->add_dataset_trigger( "eprint", EP_TRIGGER_STATUS_CHANGE, sub{
    my( %o ) = @_;
 
    my $eprint = $o{dataobj};
    my $old_status = $o{old_status};
    my $new_status = $o{new_status};
 
    my $session = $eprint->get_session;
 
    my $user = $eprint->get_user(); #user that only editor/administrator only
 
    my $user_email = $user->get_value( "email" ); #when you are testing, set this to your email - so you don't spam people!
 

 
#   EXAMPLE of a deposit receipt
   if( $old_status eq "inbox" && $new_status eq "buffer" ){
       # send a deposit receipt?
       # Do something similar to the stuff below - but with different phrases!

        my $title = $eprint->render_value( "title" );
        my $users_name = $user->render_value( "name" );
 
        my $mail = $session->make_element( "mail" );
        $mail->appendChild( $session->html_phrase( "status_change_inbox_to_review_body",
            users_name => $users_name,
                 title => $title
        ) );
 
        my $userMailOK = EPrints::Email::send_mail(
            session => $session,
            langid => $session->get_langid,
            to_email => #EDITOR OR ADMINISTRATOR EMAIL?,
            subject => $session->phrase( "status_change_inbox_to_review_subject" ),
            message => $mail,
            sig => $session->html_phrase( "mail_sig" )
        );
 
   }
 
 
#    NOTIFICATION FOR LIVE ARCHIVE
   
    if( $old_status eq "buffer" && $new_status eq "archive" ){
        # you might want to check what the datestamp is - and not send an email if this item has
        # been moved from archive -> buffer -> archive for some reason.
 
        my $title = $eprint->render_value( "title" );
        my $users_name = $user->render_value( "name" );
        my $url = "" $eprint->get_url );
        $url->appendChild( $session->make_text( $eprint->get_url ) );
 
        my $mail = $session->make_element( "mail" );
        $mail->appendChild( $session->html_phrase( "status_change_buffer_to_archive_user_body",
            users_name => $users_name,
                 title => $title,
            eprint_url => $url
        ) );
 
        my $userMailOK = EPrints::Email::send_mail(
            session => $session,
            langid => $session->get_langid,
            to_email => $user_email,
            subject => $session->phrase( "status_change_buffer_to_archive_user_subject" ),
            message => $mail,
            sig => $session->html_phrase( "mail_sig" )
        );
 
        # you could check the value of $userMailOK - in case the email wasn't sent
    } # END of buffer-to-archive
 
});

Thank you

 

On Tue, Jan 30, 2018 at 5:13 PM, John Salter <J.Salter@leeds.ac.uk> wrote:

Hi Agung,

 

Yes - there is a way to do this.

I wrote this page a while ago to explain how - let me know if there are parts that you don't understand!

 

https://wiki.eprints.org/w/Sending_email_when_item_is_made_live_or_deposited

 

Cheers,

John

 

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Ajunk Pracetio
Sent: 28 January 2018 06:52
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Ask about frequency of items-under-review mailings:

 

Hi,

Is it possible to send email frequencies directly to the editor whenever a depositor uploads an item? Because the setting is only once per day.

If you have to make modifications, which files should I edit?

thank you.

Greetings,
Agung P.W


--

Life isn't valuable if you don't have someone to care


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/




--

Life isn't valuable if you don't have someone to care


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/




--

Life isn't valuable if you don't have someone to care

-- The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302). The Open University is authorised and regulated by the Financial Conduct Authority in relation to its secondary activity of credit broking.