LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-12-2004, 01:05 PM   #1
paperdiesel
Member
 
Registered: Oct 2003
Location: southern cali
Distribution: fedora core 4
Posts: 79

Rep: Reputation: 15
need a command line email program


I need some advice:

Can someone please recommend a good command line-driven (or capable) mail program?

Here's what I want to do:

- Generate the text of an email in a script and dump it to a file.
- Read in the contents of that file into an email and sent it to a person.

I tried using sendmail, but I can't get sendmail to send to my isp email account. My ISP thinks I'm sending spam (I think it blocks all emails from localhost.localdomain). Even though I populated the /etc/hosts file with an IP and host name, sendmail won't work. I tried turning on those spoofing options in sendmail.mc, to no avail. Here's the kicker - on an older laptop running fedora core 1, I can get it to email my isp account. On fedora core 2 on the newer laptop, they get bounced. I tried comparing the configs and I'm at a loss to explain it, so I'm giving up on sendmail.

Anyone know of a good program that can do this?
 
Old 07-12-2004, 01:15 PM   #2
BluePyre
Member
 
Registered: Mar 2004
Location: London
Distribution: Mandrake 10
Posts: 172

Rep: Reputation: 30
I'm not sure there'd be much success with any email program if your ISP regards it as spam.

You could execute this program from a webserver and use a Perl script to send the email for you.
 
Old 07-12-2004, 01:27 PM   #3
paperdiesel
Member
 
Registered: Oct 2003
Location: southern cali
Distribution: fedora core 4
Posts: 79

Original Poster
Rep: Reputation: 15
Well, I have a legitimate account on the isp and I know the smtp server info. Also, on the laptop sitting right next to it, I can somehow send email (using sendmail) the exact same way, and it gets through.

I heard that you can configure Postfix to deliver mail indirectly via a relay host. But does postfix work from the command line? I need the process to be automated in a script, so I need a command line executable program (NOT simply text-interface).

what do you mean I could execute the program from a web server? What web server? I don't understand.

Last edited by paperdiesel; 07-12-2004 at 01:30 PM.
 
Old 07-12-2004, 03:11 PM   #4
paperdiesel
Member
 
Registered: Oct 2003
Location: southern cali
Distribution: fedora core 4
Posts: 79

Original Poster
Rep: Reputation: 15
I found the solution, just in case anyone cares:

I downloaded and tried both postfix and pine. Pine DOES accept fully-automated commands and messages from the command line, as does postfix. Postfix has an interface identical to sendmail (use sendmail.postfix instead).

Pine worked well, except that it uses sendmail to actually send the message, which of course got bounced back.

Postfix has an option in its config file (main.cf) to designate your isp's smtp server, so you can send your messages the "safe" way and the isp won't bounce them back. I put in my isp's smtp server info, fired up postfix, and voila. It worked.

I must say, however, that it took me longer than it should have to figure out that postfix's sending command was identical to sendmail's. There's lots of documentation on how to configure postifx, but almost zero on how to USE it.

Thanks, all!
 
Old 07-12-2004, 03:27 PM   #5
BluePyre
Member
 
Registered: Mar 2004
Location: London
Distribution: Mandrake 10
Posts: 172

Rep: Reputation: 30
Nice to hear it worked out
 
Old 07-26-2004, 07:27 PM   #6
mscollins1
LQ Newbie
 
Registered: Apr 2004
Location: Central California
Distribution: RH, Debian
Posts: 7

Rep: Reputation: 0
Would like some details

Paperdiesel,

I'd love to hear some of the details on how you accomplished your feat. I am trying to do something very similar. I need to be able to send an email from a command line, launched by a script. I, too, have an email account on an ISP. I also had a devil of a time with sendmail so I installed Postfix.

I have thus far been unable to figure it all out. I am a Linux newbie and a recent Perl convert. I am a veteran of using the "other" operating system and have been working in IT for 10+ years. I'm sure I could figure it all out but I prefer not to reinvent the wheel when someone else has already done the work. Besides, I'm sure you know how frustrating and time-consuming it is to hammer away at something and having it never work, no matter what you try!

Would you mind posting the changes you made to /etc/postfix/main.cf as well as the command line you use to send the email? Last question: did you need to actually use the email account from your ISP, or did you simply find a way to send the mail to your ISP's SMTP server and let it do the rest?

Thanks,
MC
 
Old 07-27-2004, 12:24 AM   #7
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 51
no need for a mail server just to send out some file as mail
a python script will do it real easy
i will try (this is very simple and you can make it more elaborate as needed)
just save this as mail.py
and run it with
python mail.py
it will send a file from the same directory named mail.txt
change the server name etc to fit
Code:
#!/usr/bin/python
import  smtplib
f = open("mail.txt", 'r')
text = f.read()
server = smtplib.SMTP("smtp.myISP.com")
server.sendmail('sender@myISP.com', 'recipient@theirISP.com', text)
server.quit()
 
Old 07-27-2004, 02:36 PM   #8
mscollins1
LQ Newbie
 
Registered: Apr 2004
Location: Central California
Distribution: RH, Debian
Posts: 7

Rep: Reputation: 0
Thumbs up Duh...

Paperdiesel,

Now I feel silly! I *KNEW* that I was making this too complicated! I don't know Python but I'm getting pretty handy with PERL. I'm sure that I can find a package that will will allow me to do what I want to do.

Thanks for your input!

-MC
 
Old 07-29-2004, 08:43 AM   #9
paperdiesel
Member
 
Registered: Oct 2003
Location: southern cali
Distribution: fedora core 4
Posts: 79

Original Poster
Rep: Reputation: 15
mscollins,

That reply to your first post was not from me, scroll up .

Anyway, to answer your questions,

Sure, I'll post the changes to my main.cf file. Essentially, there's a line in that file where you can tell postfix to bounce the outgoing message off of an existing mail server (your ISPs SMTP server), instead of the classic sendmail method of sending it directly to the net. You have to modify a few other lines as well. The document I used for reference is here:

http://www.postfix.org/BASIC_CONFIGURATION_README.html

Here's what I have in my main.cf file:
Code:
# INTERNET HOST AND DOMAIN NAMES
# 
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
myhostname = whatever.mydomain.com
#myhostname = virtual.domain.tld

scroll, scroll

# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain = mydomain.com

scroll, scroll

# SENDING MAIL
# 
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites.  If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
myorigin = $myhostname
#myorigin = $mydomain
# INTERNET OR INTRANET

scroll, scroll

# The relayhost parameter specifies the default host to send mail to
# when no entry is matched in the optional transport(5) table. When
# no relayhost is given, mail is routed directly to the destination.
#
# On an intranet, specify the organizational domain name. If your
# internal DNS uses no MX records, specify the name of the intranet
# gateway host instead.
#
# In the case of SMTP, specify a domain, host, host:port, [host]:port,
# [address] or [address]:port; the form [host] turns off MX lookups.
#
# If you're connected via UUCP, see also the default_transport parameter.
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
relayhost = [smtp-server.myisp.com]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]
The command I use to execute it is:

cat mailfile | sendmail.postfix email@wherever.com

"mailfile" is simply a text file where I dumped the contents of the email, formatted something like this:

To: someone@wherever.com
From: me@here.com
Subject: whatever

text
blah
blah
. (the period tells sendmail.postfix to stop reading and start sending)

You need those To:, From:, and Subject: fields only if you want it to appear like a normal email.


All of this being said, if you're using this config to spam, then god have mercy on your soul.
 
Old 09-05-2006, 06:26 AM   #10
trox
Member
 
Registered: Jan 2006
Distribution: Linux Mint 12, FreeBSD, Ubuntu 12.10, Mac OS X
Posts: 83

Rep: Reputation: 15
command line email

Quote:
Originally Posted by mscollins1
Paperdiesel,

Now I feel silly! I *KNEW* that I was making this too complicated! I don't know Python but I'm getting pretty handy with PERL. I'm sure that I can find a package that will will allow me to do what I want to do.

Thanks for your input!

-MC
Hey, I'm learning PERL and using pine also. If you get a perl script for this before I do, let me know and I will do the same.

Thanks
 
Old 09-05-2006, 06:32 AM   #11
trox
Member
 
Registered: Jan 2006
Distribution: Linux Mint 12, FreeBSD, Ubuntu 12.10, Mac OS X
Posts: 83

Rep: Reputation: 15
Pine

Just curious anyone. Do I need to be logged into a Unix server to use pine? Or can I just use my home computer with an internet connection? I have my pine account set up and have tried unsuccessfuly e-mailing myself several times at my yahoo and .mac accounts. The mail shows as sent in the sent folder and does not show up as spam or junk in my yahoo or .mac accounts. When I send mail to myself on my system obviously it works just fine. Any ideas?

Thanks
 
  


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
command-line email sending ixion Linux - Software 9 08-01-2008 06:46 AM
send email from command line djionel82 Programming 6 11-29-2005 12:12 AM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM
command-line email success darthtux LinuxQuestions.org Member Success Stories 4 08-31-2003 11:57 PM
command-line email client ixion Linux - General 4 02-11-2003 02:28 PM


All times are GMT -5. The time now is 02:32 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration