Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Email::Sender does not work and I don't know where to start figuring it out

by xtpu2 (Acolyte)
on Jun 03, 2014 at 21:34 UTC ( [id://1088524]=perlquestion: print w/replies, xml ) Need Help??

xtpu2 has asked for the wisdom of the Perl Monks concerning the following question:

Edited to Add: My apologies to the monks. You are correct, the question was idiotic. I should certainly know better. My only excuse is that it was the end of a long and frustrating day, and I was beginning to come down with a fever, which I'm still in the midst of. Editing the question to add the required details.

I'm trying to get Email::Sender to work. Here is my code:

#!/usr/bin/perl use strict; use warnings; use Email::MIME; use Email::Sender::Simple; my ($from, $to, $subject, $body) = ('some','values','go','here'); my $message = Email::MIME->create( header_str => [ From => $from, To => $to, Subject => $subject ], attributes => { encoding=> 'quoted-printable', charset => 'UTF-8' }, body_str => $body ); Email::Sender::Simple->send( $message ); print "Success!";

This code doesn't work. By this I mean: the e-mail is simply not sent. There is no error message. There is no warning. The script prints "Sucess!" That's it. This is why I'm lost.

I'm also open to using a different module. I was just trying to find something ready-made and easy to use.

  • Comment on Email::Sender does not work and I don't know where to start figuring it out
  • Download Code

Replies are listed 'Best First'.
Re: Email::Sender does not work and I don't know where to start figuring it out
by tobyink (Canon) on Jun 03, 2014 at 22:41 UTC

    "This code doesn't work, and the module's documentation isn't exactly enlightening."

    Your question isn't exactly enlightening either.

    Pray tell us, what does "doesn't work" mean? When you run it, does it cause your house to burn down? Does it cause a pain in your left knee? Did your puppy die? Do you get an unpleasant metallic taste in your mouth? Or just an eerie feeling you can't quite explain to anybody?

    I'm sure it doesn't produce an error message, does it? Because if it produced an error message, you would have quoted the error message in your original question, right?

    </sarcasm>

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

      My apologies. Your criticism is apt. Question has been edited with details.

        Have you read the manual? In particular:

        Email::Sender::Simple tries to make a good guess about how to send the message. It will usually try to use the sendmail program on unix-like systems and to use SMTP on Windows.

        Are you on a Unix-like system? If so, do you have a program called sendmail available? If so, is it correctly configured to send mail? Can you send mail using it from the command line?

        Otherwise, is Email::Sender::Simple falling back to using SMTP? If so, have you set the correct environment variables so that it can find your SMTP server?

        If the SMTP server is under your control, have you checked the logs to see if it's getting that far? If the SMTP server is not under your control, have you tried setting up your own SMTP server temporarily for testing this?

        use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
Re: Email::Sender does not work and I don't know where to start figuring it out
by GotToBTru (Prior) on Jun 03, 2014 at 21:41 UTC

    A slightly more informative example:

    use strict; use Email::Sender::Simple qw(sendmail); use Email::Simple; use Email::Simple::Creator; my $email = Email::Simple->create( header => [ To => '"Xavier Q. Ample" <x.ample@example.com>', From => '"Bob Fishman" <orz@example.mil>', Subject => "don't forget to *enjoy the sauce*", ], body => "This message is short, but at least it's cheap.\n", ); sendmail($email);

    I started by entering Email::Sender::Simple into Google. That got me to the cpan page. Under "See Instead" was a link to Email::Sender::Manual::Quickstart which had the above example, and more details.

    1 Peter 4:10
Re: Email::Sender does not work and I don't know where to start figuring it out
by taint (Chaplain) on Jun 04, 2014 at 00:38 UTC
    Greetings, xtpu2.
    Where would I even begin unraveling this?

    May I suggest

    use strict; # always use warnings; # for helpful hints # and when things REALLY get tough use diagnostics;
    I know that doesn't seem to speak directly to your question. But in all honesty, I think it would really help -- see; does. :)

    Best wishes.

    --Chris

    ¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

      My apologies. Question as posted was idiotic. I've edited the OP to add details.

Re: Email::Sender does not work and I don't know where to start figuring it out
by Theodore (Friar) on Jun 04, 2014 at 08:06 UTC

    I'm also open to using a different module. I was just trying to find something ready-made and easy to use.

    May i suggest Mail::Sender?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-24 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found