Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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 ( [id://1099037]=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^3: Need to send an email through my SMTP server using Perl
by socketdave (Curate) on Aug 29, 2014 at 21:07 UTC
    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;
Re^3: Need to send an email through my SMTP server using Perl
by faber (Acolyte) on Sep 03, 2014 at 05:44 UTC
    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 }); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1099037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-28 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found