Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184
Rep:
How to send email from command line?
I'm looking for an easy way to send basic emails for the command line. I have tried configuring sendmail and mailx, but I have yet been able to receive a test email at my remote address.
I have read through a fair amount of "how to" on this but I am a little confused and obviously not doing something right.
# mail -s "Hello world" myemail@gmail.com
test mail
EOT
I see
Code:
send-mail -i myemail@gmail.com
running in the process list for a while and then it goes away, but I never actually receive the email at my gmail account(I have also check the spam folder just in case). I have also tried sending the test email to my work email address, but that doesn't work either.
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184
Original Poster
Rep:
Quote:
Originally Posted by szboardstretcher
try this test:
Code:
sendmail -v someemail@somewhere.com
some text
.
(press "period and then enter" to end)
Post output
So I tried your suggestion, here is the output.
Code:
~ # sendmail -v myemail@gmail.com
test mail2
.
myemail@gmail.com... Connecting to [127.0.0.1] via relay...
myemail@gmail.com... Deferred: Connection refused by [127.0.0.1]
I'm only a moderately competent user but, although it was simple enough to setup fetchmail, procmail and mailx for receiving mail I never managed to get sendmail to work.
Are you just trying to send through a remote smtp server, like through the smtp at gmail or yahoo? Or are you trying to run a full mail server? If it's the first then I'd recommend ssmtp, which I got working in about five minutes, which is less time than it took me to fail with sendmail by a very long way.
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184
Original Poster
Rep:
Quote:
Originally Posted by Stephen Morgan
I'm only a moderately competent user but, although it was simple enough to setup fetchmail, procmail and mailx for receiving mail I never managed to get sendmail to work.
Are you just trying to send through a remote smtp server, like through the smtp at gmail or yahoo? Or are you trying to run a full mail server? If it's the first then I'd recommend ssmtp, which I got working in about five minutes, which is less time than it took me to fail with sendmail by a very long way.
I do not want to send my emails through a remote smtp server, since there is a good change my system will be running on a closed network. Maybe my issue is that I don't have a smtp server running locally. I though sendmail took care of that, but I may be wrong. What do I need to do to run the smtp server on my system?
~ # sendmail -v myemail@gmail.com
test mail2
.
myemail@gmail.com... Connecting to [127.0.0.1] via relay...
myemail@gmail.com... Deferred: Connection refused by [127.0.0.1]
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184
Original Poster
Rep:
Quote:
Originally Posted by szboardstretcher
type
Code:
service sendmail start
So do I really need the sendmail service running to only send emails? I seems like if all I want to do is send emails it could just invoke sendmail when I try to send an email rather than having it running always.
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184
Original Poster
Rep:
Ok, so I started up my sendmail service. I am currently using postfix for my sendmail server. It looks like it is trying to actually send the email to the gmail-smtp server now, but it keeps getting connection refused. (I also get connection refused when trying to send to my work email as well. Here is the output in the maillog.
Code:
postfix/pickup[1415]: 5789B374577: uid=0 from=<root>
postfix/cleanup[1538]: 5789B374577: message-id=<20110303174111.5789B374577@hostname.localdomain>
postfix/cleanup[1538]: warning: file system clock is 203 seconds ahead of local clock
postfix/cleanup[1538]: warning: resetting file time stamps - this hurts performance
postfix/qmgr[1416]: 5789B374577: from=<root@hostname.localdomain>, size=457, nrcpt=1 (queue active)
postfix/smtp[1540]: connect to gmail-smtp-in.l.google.com[74.125.155.27]:25: Connection refused
postfix/smtp[1540]: connect to alt1.gmail-smtp-in.l.google.com[74.125.65.27]:25: Connection refused
postfix/smtp[1540]: connect to alt2.gmail-smtp-in.l.google.com[74.125.45.27]:25: Connection refused
postfix/smtp[1540]: connect to alt3.gmail-smtp-in.l.google.com[74.125.115.27]:25: Connection refused
postfix/smtp[1540]: connect to alt4.gmail-smtp-in.l.google.com[74.125.77.27]:25: Connection refused
postfix/smtp[1540]: 5789B374577: to=<myemail@gmail.com>, relay=none, delay=0.42, delays=0.39/0.02/0.01/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[74.125.77.27]:25: Connection refused)
I suggest you to look at my tutorial which is a step-by-step guide to mail and mutt programs, however not technically in-depth, but still it serves a good kick-start.
I suggest you to look at my tutorial which is a step-by-step guide to mail and mutt programs, however not technically in-depth, but still it serves a good kick-start.
Thanks for pointing me to your blog, but it doesn't look like it is going to help me much. I can't even get the "Basic usage of mail" to work and it doesn't seem to cover mail server/domain configuration (where I think my issue lies).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.