Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Net::SMTP

    Hello,

    I'm trying to send mail using the Net::SMTP module, but am having
    difficulties. I'm not using Perl, I'm using "ccperl", which comes with
    ClearCase. So I'm limited to the mail modules that came standard with the
    installation: Mail::Mailer, Mail::Mailer::sendmail, Net::SMTP... Here's my
    code:

    use Net::SMTP;
    sub send_mail
    {
    $send_to = 'someone@someplace.com';
    $server = 'my_server.com';
    $smtp = new Net::SMTP ('host', Hello=>$server);

    $smtp->mail($ENV{USER});
    $smtp->to($send_to);

    $smtp->data();
    $smtp->datasend("To: whomever");
    $smtp->datasend("\n");
    $smtp->datasend("Test");
    $smtp->dataend();

    $smtp->quit;
    }

    This is the error:

    %cmd> ccperl cclibrpt.pl
    "connect: The requested address is not valid in its context.
    at cclibrpt.pl line 149"

    The line being referred to is the $smtp = new... line
    -- -------
    Thanks,
    Erik Waibel
    ----------
    Perl Hacker v.1.0


    Erik Waibel Guest

  2. Similar Questions and Discussions

    1. CDO and SMTP
      I want to use the CDO instead of CDONTS running via Server 2003. Within the sample code it asks for the SMTP server name. Once I've installed the...
    2. PHP 5 & SMTP
      Anyone know if PHP 5 has built in support for communicating with SMTP servers that require a username and password? Right now, as everyone knows,...
    3. SMTP for ASP
      Hi Group, I'm having a few problems with getting an SMTP server configured on my Windows 2000 Server web server. My web server is co-located at my...
    4. How to set sendmail SMTP auth and SMTP SSL on Solaris 9 (x86)
      Dear all, Can anybody tell me how to set sendmail SMTP auth and SMTP SSL on Solaris 9(x86). Thanks!
    5. SMTP
      I am having a problem with sending mail via system.web.mail. When I send the file shows up in the queue folder so something is not letting it go,...
  3. #2

    Default Net::SMTP

    Hi.
    I`ve got problem with module Net::SMTP. I want to check my SMTP server
    is working proparly so i run this script:
    #!/usr/bin/perl -w

    use Net::SMTP;
    $smtp = Net::SMTP -> new('100.100.100.100',
    Hello => 'my_name.ma_domain',
    Timeout => 10,
    Debug => 1
    );


    $smtp->mail('admin@');
    $smtp->to('postmaster');
    $smtp->quit;

    Debug:
    bash-3.00# ./sesja_smtp1.pl
    Can't call method "mail" on an undefined value at ./sesja_smtp1.pl line
    9.

    I want to write to log some memo when my SMTP server don`t answer to
    any of this commands.
    Is it possible ?

    I found something like that in documentation:
    "Unless otherwise stated all methods return either a true or false
    value, with true meaning that the operation was a success. When a
    method states that it returns a value, failure will be returned as
    undef or an empty list."
    But i don`t know how to use it with if ore while commands.

    Thx for help.

    Sqrex Guest

  4. #3

    Default Re: Net::SMTP

    "Sqrex" <sqrex@poczta.fm> writes:
    > Hi.
    > I`ve got problem with module Net::SMTP. I want to check my SMTP server
    > is working proparly so i run this script:
    > #!/usr/bin/perl -w
    >
    > use Net::SMTP;
    > $smtp = Net::SMTP -> new('100.100.100.100',
    > Hello => 'my_name.ma_domain',
    > Timeout => 10,
    > Debug => 1
    > );
    >
    >
    > $smtp->mail('admin@');
    > $smtp->to('postmaster');
    > $smtp->quit;
    >
    > Debug:
    > bash-3.00# ./sesja_smtp1.pl
    > Can't call method "mail" on an undefined value at ./sesja_smtp1.pl line
    > 9.

    use Net::SMTP;
    $smtp = Net::SMTP -> new('100.100.100.100',
    Hello => 'my_name.ma_domain',
    Timeout => 10,
    Debug => 1
    );

    if( !defined($smtp)){
    # $smtp object have not been created. Problem report is in $@
    die $@;
    }
    > [...]

    --
    [pl2en: Andrew] Andrzej Adam Filip : [email]anfi@priv.onet.pl[/email] : [email]anfi@xl.wp.pl[/email]
    Andrzej Adam Filip Guest

  5. #4

    Default Re: Net::SMTP

    this work but there is another problem. when i receive error message
    program ends and i want it to go to next command not to end.

    it ends with error:
    Net::SMTP: connect: timeout (this is from print $@)
    Can't call method "mail" on an undefined value at ./smtp.pl line 11.
    end it ends :/

    > use Net::SMTP;
    > $smtp = Net::SMTP -> new('100.100.100.100',
    > Hello => 'my_name.ma_domain',
    > Timeout => 10,
    > Debug => 1
    > );
    >
    > if( !defined($smtp)){
    > # $smtp object have not been created. Problem report is in $@
    > print $@;
    > }
    $smtp->mail("test\@test.com");

    Sqrex Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139