LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-24-2009, 12:03 PM   #1
hawk__0
Member
 
Registered: Nov 2008
Posts: 105

Rep: Reputation: 15
Perl email::send.. how to send the email?


I followed the example on the cpan page, and at the end it prints the email on the terminal. How do I actually send the email?
 
Old 12-24-2009, 12:28 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
After a quick search for similar Perl functions, it appears some of these functions just call an external tool, (i.e. "sendmail", a simple Unix command-line tool). If your on Linux then you probably have one of these tools built in and just need to point to where its located.

Alternatively, you might be able to use this (without any external requirements): http://search.cpan.org/~gbarr/libnet-1.21/Net/SMTP.pm. Just start with one of the number of examples on that page.

If you have problems then post your code.
 
Old 12-24-2009, 12:51 PM   #3
hawk__0
Member
 
Registered: Nov 2008
Posts: 105

Original Poster
Rep: Reputation: 15
<double post>

Last edited by hawk__0; 12-24-2009 at 12:52 PM.
 
Old 12-24-2009, 12:52 PM   #4
hawk__0
Member
 
Registered: Nov 2008
Posts: 105

Original Poster
Rep: Reputation: 15
Here is the chunk of code that does the email. I am running linux, but using mutt instead of sendmail

Code:
					open TEXT, "< ~/report.txt";
					my $msg = *TEXT;
					my $email = Email::Simple->create(
						header => [
							From	=> 'sgregory@elandatamakers.com',
							To	=> 'steve@staticg.com',
							Subject	=> 'Daily Report',
							],
						body => $msg,
					);
					$email->header_set( 'X-Content-Container' => 'bottle/glass' );
					print $email->as_string;

					print "Email sent.  Press enter to continue.";
					<>;
				}
				}
			}

}
 
Old 12-24-2009, 01:12 PM   #5
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Quote:
Originally Posted by CPAN
Email::Simple - simple parsing of RFC2822 message format and headers
It seems the module your using has nothing to do with sending an email. It only prepares the email for sending. After you have prepared the email (i.e. your code above), you might be able to just send the email using your command-line email tool with the content of the email being "$email->as_string". Look up the man page for whatever tool your using, and see how you can pass the entire email (headers/body) to the tool for it to send. Once you've figured out the arguments, then simply call the tool in your Perl script.
 
Old 12-24-2009, 01:22 PM   #6
hawk__0
Member
 
Registered: Nov 2008
Posts: 105

Original Poster
Rep: Reputation: 15
Thanks, I think I'll try the SMTP module.
 
Old 12-24-2009, 01:53 PM   #7
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by hawk__0 View Post
Thanks, I think I'll try the SMTP module.
CPAN has a whole bunch of Email related modules - just search and select a good one.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail to root but it send to other email smart_jija Solaris / OpenSolaris 5 07-01-2009 01:33 AM
Send email to specific SMTP servers per email from my server? neilius Linux - Server 6 06-25-2009 06:31 AM
Apache virtual host send email without email server SibLiant Linux - Software 6 06-03-2009 09:46 PM
LXer: Perl script to monitor disk space and send an email alert LXer Syndicated Linux News 1 02-23-2007 01:12 PM
send email using PERL just_a_kid Linux - Newbie 3 01-31-2007 07:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration