mailing from a web-executed perl script.

Discussion in 'Perl' started by Nathan, Apr 3, 2006.

  1. Nathan

    Nathan Guest

    This may be a basic task to some of you perl guru's, but I have a
    problem getting a perl script i've written, when executed by httpd, to
    send out an e-mail.

    Basically, i have a few variables passed into this script, it writes
    them to a a database, and then its supposed to read the "E-mail list"
    attached to that database entry and shoot an e-mail off to everyone in
    that list letting them know that there's been an update.
    I have what would seem like all of the difficult things done! It takes
    the variables, writes them to the database, reads the list (which is
    currently only my e-mail address" and then sends the message. The
    problem is that the message is empty!
    If i execute the script at a shell it works flawlessly (i need to
    substitute some variables instead of the HTTP POST that it uses via a
    browser, but it works none the less!). I'm starting to wonder weather
    its my code or a unix permissions thing.

    Basically, when its executed from a shell, it sends the message, the
    subject and body are correct, but when i run it from a web browser it
    results in a message, with no subject, and no body.

    Here's the line which i'm using to try to execute the mail command:

    system "/bin/echo $entry | /bin/mail -s \"Log entry added to TN:
    $ticketnum\" $emaillist[0]";

    I know it may not be the best way to do it, but like i said, it works if
    i execute it from a shell. This is my first big perl project, so be
    nice. :)

    Thanks!
    --
    In a world with no fences, why do I need Gates?
     
    Nathan, Apr 3, 2006
    #1
    1. Advertising

  2. Nathan

    Nathan Guest

    I've gotten this working using sendmail. My script writes the e-mail to
    temporary file, and then pipes that file through sendmail.
    But, it would still be great to be able to just use a one-liner to send
    it through mail instead.

    Any suggestions are still welcome.

    Thanks!

    Nathan wrote:
    > This may be a basic task to some of you perl guru's, but I have a
    > problem getting a perl script i've written, when executed by httpd, to
    > send out an e-mail.
    >
    > Basically, i have a few variables passed into this script, it writes
    > them to a a database, and then its supposed to read the "E-mail list"
    > attached to that database entry and shoot an e-mail off to everyone in
    > that list letting them know that there's been an update.
    > I have what would seem like all of the difficult things done! It takes
    > the variables, writes them to the database, reads the list (which is
    > currently only my e-mail address" and then sends the message. The
    > problem is that the message is empty!
    > If i execute the script at a shell it works flawlessly (i need to
    > substitute some variables instead of the HTTP POST that it uses via a
    > browser, but it works none the less!). I'm starting to wonder weather
    > its my code or a unix permissions thing.
    >
    > Basically, when its executed from a shell, it sends the message, the
    > subject and body are correct, but when i run it from a web browser it
    > results in a message, with no subject, and no body.
    >
    > Here's the line which i'm using to try to execute the mail command:
    >
    > system "/bin/echo $entry | /bin/mail -s \"Log entry added to TN:
    > $ticketnum\" $emaillist[0]";
    >
    > I know it may not be the best way to do it, but like i said, it works if
    > i execute it from a shell. This is my first big perl project, so be
    > nice. :)
    >
    > Thanks!



    --
    In a world with no fences, why do I need Gates?
     
    Nathan, Apr 4, 2006
    #2
    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,872
  2. Cédric Rossé
    Replies:
    1
    Views:
    549
    Cédric Rossé
    Nov 9, 2004
  3. jeremy redburn
    Replies:
    3
    Views:
    3,167
    jeremy redburn
    Nov 25, 2003
  4. Tom Parson
    Replies:
    0
    Views:
    163
    Tom Parson
    Dec 30, 2003
  5. Perl Mailing List script

    , Feb 1, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    208
    Keith Keller
    Feb 1, 2006
Loading...

Share This Page