Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Send a PHP array to a Perl script (http://www.velocityreviews.com/forums/t907181-send-a-php-array-to-a-perl-script.html)

techusky@gmail.com 04-21-2008 07:57 PM

Send a PHP array to a Perl script
 
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).

nolo contendere 04-21-2008 08:03 PM

Re: Send a PHP array to a Perl script
 
On Apr 21, 3:57*pm, techu...@gmail.com 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

sopan.shewale@gmail.com 04-21-2008 08:43 PM

Re: Send a PHP array to a Perl script
 
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, techu...@gmail.com 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).




All times are GMT. The time now is 01:38 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.