in reply to Need to send an email through my SMTP server using Perl

Add a semicolon. Change:
use Net::SMTP

to:

use Net::SMTP;

You need one after your "new" line, too.

I figured this out by deleting most of your lines of code until the error disappeared.

Replies are listed 'Best First'.
Re^2: Need to send an email through my SMTP server using Perl
by Logic_Bomb421 (Novice) on Aug 29, 2014 at 19:13 UTC

    It's always a damn semicolon! Ah well. I went ahead and fixed those and now it's saying it can't call method put() on an undefined value.

      Even if you clean up personal information, you should still post code that will run. Also, be sure to post the entire error message. Did you delete the content you're assigning to 'Hello'? That would yield something like the error you mention in your reply. It should do a decent job of picking a helo line for you.
      use strict; use warnings; use Net::SMTP; $host = "mail.host.com"; $port = 25; $smtp = Net::SMTP->new($host, port=>$port); $smtp->mail("test\@domain.com"); $smtp->recipient("test\@domain2.com"); $smtp->data; $smtp->datasend("From: test\@domain.com"); $smtp->datasend("To: test\@domain2.com"); $smtp->datasend("Subject: Test"); $smtp->datasend("\n"); $smtp->datasend ("This is a test"); $smtp->dataend; $smtp->quit;
      Really you're going to find it much easier in the long wrong (espcially to manage) to just utilize Email::Sender::Simple with Email::Simple::Creator: here's an easy to understand example:
      my $email = Email::Simple->create( header => [ To => $p->{email_to}, Cc => $p->{email_cc}, From => $CONF->{smtp}->{from}, Subject => $sub ], body => $str ); if($DRYRUN){ print "---- EMAIL ----\n${$email->{body}}\n---- END FO + EMAIL ----\n" if $DEBUG; } elsif($CONF->{smtp}->{enabled}) { # Do some more emailing and stuff below... my $transport; $transport = Email::Sender::Transport::SMTP->new({ host => $CONF->{smtp}->{hos +t}, port => $CONF->{smtp}->{por +t}, ssl => $CONF->{smtp}->{ssl +}, sasl_username => $CONF->{smtp}->{sas +l_username}, sasl_password => $CONF->{smtp}->{sas +l_password}, allow_partial_success => $CONF->{smtp}->{all +ow_partial_success}, helo => $CONF->{smtp}->{hel +o}, localaddress => $CONF->{smtp}->{loc +aladdress}, localport => $CONF->{smpt}->{loc +alport}, timeout => $CONF->{smpt}->{tim +eout} }); sendmail($email, { transport => $transport }); }