Send a PHP array to a Perl script

Discussion in 'Perl Misc' started by techusky@gmail.com, Apr 21, 2008.

  1. Guest

    First off, I am not sure where exactly to post this, so I'm posting to
    both php.general and here...

    My general problem is that I am wondering if there is a(n effective)
    way to send an array from a PHP script to a Perl script. I am
    developing a simple Perl script to handle automated e-mails from my
    website (which is written exclusively in PHP). I would ordinarily just
    stick with PHP as far as e-mailing is concerned, but I have found it
    to be much more a pain trying to connect to my Gmail account via
    sockets to send e-mail; the Perl route is much simpler in my opinion.

    I have a form on my website that will let me specify to which users
    from my site I would like to send the e-mail. Upon submitting the
    form, the PHP script parses the e-mail addresses from
    $_POST['user_emails'] and puts them into an array. Then what happens
    is that I do something to the effect of:

    foreach($user_emails as $user) {
    [some code omitted here that generates the perl script]
    shell_exec("perl \"./email.user.pl\"");

    }

    Essentially, what this does is sends out individual e-mails to each
    user (it takes roughly 5-8 seconds for it to send out one e-mail, so
    you can imagine if I try to send to 100 users that it takes quite a
    while). But we all know that you can send a single e-mail to many
    different people at the same time... This is why I am trying to send
    PHP's array to my Perl script, because I could then easily add each
    element in the array to one e-mail.

    Any ideas? Sorry if my problem isn't clear (or if there is some
    stupidly simple solution I am not thinking of... I'm not that fluent
    in Perl yet).
     
    , Apr 21, 2008
    #1
    1. Advertising

  2. On Apr 21, 3:57 pm, wrote:
    > First off, I am not sure where exactly to post this, so I'm posting to
    > both php.general and here...
    >
    > My general problem is that I am wondering if there is a(n effective)
    > way to send an array from a PHP script to a Perl script. I am
    > developing a simple Perl script to handle automated e-mails from my
    > website (which is written exclusively in PHP). I would ordinarily just
    > stick with PHP as far as e-mailing is concerned, but I have found it
    > to be much more a pain trying to connect to my Gmail account via
    > sockets to send e-mail; the Perl route is much simpler in my opinion.
    >
    > I have a form on my website that will let me specify to which users
    > from my site I would like to send the e-mail. Upon submitting the
    > form, the PHP script parses the e-mail addresses from
    > $_POST['user_emails'] and puts them into an array. Then what happens
    > is that I do something to the effect of:
    >
    > foreach($user_emails as $user) {
    > [some code omitted here that generates the perl script]
    > shell_exec("perl \"./email.user.pl\"");
    >
    > }
    >
    > Essentially, what this does is sends out individual e-mails to each
    > user (it takes roughly 5-8 seconds for it to send out one e-mail, so
    > you can imagine if I try to send to 100 users that it takes quite a
    > while). But we all know that you can send a single e-mail to many
    > different people at the same time... This is why I am trying to send
    > PHP's array to my Perl script, because I could then easily add each
    > element in the array to one e-mail.
    >
    > Any ideas? Sorry if my problem isn't clear (or if there is some
    > stupidly simple solution I am not thinking of... I'm not that fluent
    > in Perl yet).


    You could build a string from your PHP's array contents, joined by
    whatever delimiter (it should show up in the email addresses), and
    then pass that to the Perl script. Within the Perl script, split the
    string to get your individual email addresses back. There are a number
    of Mail modules for Perl--I know of at least one that takes comma
    separated emails (Mail::Sender, I think). Also, you could open a pipe
    to Unix's mailx, which I think takes space delimited email addresses.

    HTH
     
    nolo contendere, Apr 21, 2008
    #2
    1. Advertising

  3. Guest

    Hi,

    I think instead of trying to send mail through form/action itself -
    try following:

    [1]. Collect the mail details in some file on the server in some
    directory (call it mailq). Each form submit will create the mail file
    under mailq. So your Browser user do not have to wait till your mails
    are delivered - the speed is increased.

    [2]. Write the daemon or script (use Perl or any other language) to
    pick up the files from mailq, deliver the mails and clean those files
    once you are done.

    This will helps to remove issues because of PHP/Perl integration or
    running processes/scripts together.
    Also helps to increase the speed of your application.


    --sopan shewale
    http://sopanshewale.blogspot.com




    On Apr 21, 12:57 pm, wrote:
    > First off, I am not sure where exactly to post this, so I'm posting to
    > both php.general and here...
    >
    > My general problem is that I am wondering if there is a(n effective)
    > way to send an array from a PHP script to a Perl script. I am
    > developing a simple Perl script to handle automated e-mails from my
    > website (which is written exclusively in PHP). I would ordinarily just
    > stick with PHP as far as e-mailing is concerned, but I have found it
    > to be much more a pain trying to connect to my Gmail account via
    > sockets to send e-mail; the Perl route is much simpler in my opinion.
    >
    > I have a form on my website that will let me specify to which users
    > from my site I would like to send the e-mail. Upon submitting the
    > form, the PHP script parses the e-mail addresses from
    > $_POST['user_emails'] and puts them into an array. Then what happens
    > is that I do something to the effect of:
    >
    > foreach($user_emails as $user) {
    > [some code omitted here that generates the perl script]
    > shell_exec("perl \"./email.user.pl\"");
    >
    > }
    >
    > Essentially, what this does is sends out individual e-mails to each
    > user (it takes roughly 5-8 seconds for it to send out one e-mail, so
    > you can imagine if I try to send to 100 users that it takes quite a
    > while). But we all know that you can send a single e-mail to many
    > different people at the same time... This is why I am trying to send
    > PHP's array to my Perl script, because I could then easily add each
    > element in the array to one e-mail.
    >
    > Any ideas? Sorry if my problem isn't clear (or if there is some
    > stupidly simple solution I am not thinking of... I'm not that fluent
    > in Perl yet).
     
    , Apr 21, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,832
  2. Replies:
    1
    Views:
    1,245
    williamsio
    Jul 12, 2005
  3. Rajive Narain
    Replies:
    0
    Views:
    1,996
    Rajive Narain
    Sep 18, 2009
  4. Ignoramus6539
    Replies:
    2
    Views:
    236
    Colin McKinnon
    Aug 30, 2006
  5. M. Strobel
    Replies:
    1
    Views:
    229
    The Natural Philosopher
    Mar 5, 2013
Loading...

Share This Page