Chomp not working properly with Sendmail

Discussion in 'Perl' started by Aaron Powell, Jul 24, 2003.

  1. Aaron Powell

    Aaron Powell Guest

    I am writing a program for a study I am doing where I must contact several
    different organisations stored in a database I compiled, but I need to send
    each email one at a time so they don't know who else I sent to.

    I tested my sendmail and it works well, but I am having a problem with chomp
    in the case I am using it. When getting $email, if I do not say $email\n,
    nothing will be displayed to the command prompt. This leads me to believe
    that sendmail is also receiving nothing in the To field as its displaying no
    recipient has been specified, though it also displays that if you put data
    in that it doesn't understand, such as $email with a \n.

    Finally, it will always send the last record, the last record in the file
    works fine, the rest are the ones that are not understandable.

    Any help is appreciated, thank you.

    The code is show bellow.

    #!/usr/bin/perl

    use SendMail;

    my $message = "message"

    open (FILENO, "emails.txt");
    my @file = <FILENO>;
    close (FILENO);

    foreach $email (@file){

    $sm = new SendMail("mailserver");
    $sm->setDebug($sm->ON);
    $sm->From("me\@me.com");
    $sm->Subject("Header");
    chomp $email;
    print "$email\n";
    $sm->To("$email");
    $sm->setMailBody("$message");
    #
    # Check if the mail sent successfully or not.
    #
    if ($sm->sendMail() != 0) {
    print $sm->{'error'}."\n";
    }
    print "Done\n";
    }
    exit 0;
     
    Aaron Powell, Jul 24, 2003
    #1
    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. sugapablo
    Replies:
    0
    Views:
    2,453
    sugapablo
    Sep 21, 2007
  2. Andrzej Adam Filip
    Replies:
    0
    Views:
    4,479
    Andrzej Adam Filip
    Mar 31, 2008
  3. Peter Vanderhaden

    chomp - works in irb, not in program

    Peter Vanderhaden, Nov 23, 2007, in forum: Ruby
    Replies:
    8
    Views:
    210
    Peter Vanderhaden
    Nov 23, 2007
  4. Vister Gade

    gets.chomp....... not function

    Vister Gade, Apr 14, 2008, in forum: Ruby
    Replies:
    6
    Views:
    252
    Marc Heiler
    Apr 14, 2008
  5. Hendrik Maryns
    Replies:
    15
    Views:
    331
    Hendrik Maryns
    Jan 18, 2005
  6. Ignoramus20015

    Strange issue with `CHOMP' not working...

    Ignoramus20015, Apr 10, 2006, in forum: Perl Misc
    Replies:
    12
    Views:
    280
    robic0
    Apr 12, 2006
  7. martin
    Replies:
    3
    Views:
    302
    Joe Smith
    Apr 15, 2006
  8. John
    Replies:
    9
    Views:
    265
    Ben Bacarisse
    Oct 15, 2013
Loading...