Send email using Perl

Discussion in 'Perl Misc' started by Ning li, Sep 14, 2003.

  1. Ning li

    Ning li Guest

    Hi,

    I am new to Perl and I would like to know the Perl equivalent of this
    Unix mail command:

    mailx -s "My Subject Here" < my_file_name

    Thanks in advance.

    Nick Li
     
    Ning li, Sep 14, 2003
    #1
    1. Advertisements

  2. Ning li

    Mina Naguib Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Ning li wrote:
    > Hi,
    >
    > I am new to Perl and I would like to know the Perl equivalent of this
    > Unix mail command:
    >
    > mailx -s "My Subject Here" < my_file_name


    system qq|mailx -s "My Subject Here" < my_file_name|;

    or

    `mailx -s "My Subject Here" < my_file_name`;

    or

    open (FH, "| mailx") or die . .;
    print to FH

    or the best, perl-ish way :

    perldoc Net::SMTP

    Best of luck.


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.1 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQE/Y9pMeS99pGMif6wRAggqAKCLN9K5lM5fzboinKZpr9WrymPeBgCgjBhT
    wcLgZCyIeLgdcTK2tCyIaF8=
    =EVL3
    -----END PGP SIGNATURE-----
     
    Mina Naguib, Sep 14, 2003
    #2
    1. Advertisements

  3. Ning li

    Bill Zhao Guest

    "Ning li" <> ¼¶¼g©ó¶l¥ó
    news:I6P8b.140824$...
    > Hi,
    >
    > I am new to Perl and I would like to know the Perl equivalent of this
    > Unix mail command:
    >
    > mailx -s "My Subject Here" < my_file_name

    in perl:
    if (`mailx -s "My Subject Here" < my_file_name`) {
    die "Mail Send Fail ";
    }

    >
    > Thanks in advance.
    >
    > Nick Li
    >
    >
    >
    >
     
    Bill Zhao, Sep 15, 2003
    #3
  4. Ning li

    Sam Holden Guest

    On Mon, 15 Sep 2003 15:51:08 +0800, Bill Zhao <> wrote:
    >
    > "Ning li" <> ¼¶¼g©ó¶l¥ó
    > news:I6P8b.140824$...
    >> Hi,
    >>
    >> I am new to Perl and I would like to know the Perl equivalent of this
    >> Unix mail command:
    >>
    >> mailx -s "My Subject Here" < my_file_name

    > in perl:
    > if (`mailx -s "My Subject Here" < my_file_name`) {
    > die "Mail Send Fail ";
    > }


    Did you even think about that for a second? Did you really want to
    interpolate the array @mail into that command?

    Why does mailx indicate failure by outputting to stdout? That seems like
    a remarkably stupid way of indicating failure.

    Of course it probably doesn't. It's far more likely you just don't know
    how to execute a command correctly in perl...

    --
    Sam Holden
     
    Sam Holden, Sep 15, 2003
    #4
    1. Advertisements

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. Peter
    Replies:
    0
    Views:
    3,641
    Peter
    Jul 1, 2003
  2. Eric Osman

    how to send html email from perl

    Eric Osman, Jun 27, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    310
    Eric Osman
    Jun 27, 2003
  3. Adam S
    Replies:
    2
    Views:
    380
    Ben Morrow
    Sep 23, 2004
  4. Replies:
    2
    Views:
    580
    Tintin
    Jan 5, 2007
  5. Replies:
    13
    Views:
    818
    Randy Webb
    May 14, 2006
  6. pbd22
    Replies:
    1
    Views:
    322
  7. ashish makani
    Replies:
    5
    Views:
    1,021
    Mark Lawrence
    Sep 20, 2012
  8. heycooldude
    Replies:
    0
    Views:
    893
    heycooldude
    Mar 26, 2014
Loading...