[SOLVED] Sending email from command line through authenticated SMTP server
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Sending email from command line through authenticated SMTP server
The long story: I am setting up the Hylafax server (which is working now fine) and I want it to be able to email the received faxes to non-local email addresses as attachments.
The short story: How do I send emails from Linux command line through my Email hosting provider's authenticated SMTP server?
Most information on the net either refers to a variety of easy to use command line clients (mailx, mail etc.) which dont's seem to be able to use authentication through a non-local SMTP server (or at least nobody mentions anything about it), or postfix and sendmail (which appears to be capable of such a thing - but couldn't figure out how). I have tried the default sendmail configuration - and the email bounced back complaining about possible spam when it reached the target email server. I assume then that I need to send through my provider's smtp server, not just straight to the internet.
My question is, how do I configure easily Sendmail to send emails through my provider's smtp server (using an email account I already have with my provider, so that is not a problem), or is there another way to do this more simply (from the command line) which I could integrate with Hylafax?
Slightly parallel with this - could a kind soul please explain to me briefly how this whole thing is working out? I mean, it looks like any good old mail program use to be able to send email to the internet directly, but since the spam and anti-spam business, you have to send through a provider's smtp server, not just directly routed to the internet - otherwise your email gets rejected by the receiver's server. Is my understanding correct?
Any pointers and thoughts on the issue are appreciated. I've spent the entire day reading up on this - and I ended up being more confused then when I started. I don't understand why isn't there the equivalent of a smtp client on the command line to just send emails (with no fancy relaying, authentication and routing capabilities) - something that will just format the message for you and pass it to an authenticated smtp server - and why people end up using full blown email servers like postfix or sendmail just to send away some emails?
P.S. I am most likely attacking the problem from the perspective of traditional gui email clients - which just talk to pop3 and smpt servers for their email functions (and hoping that such a thing can be replicated - or has been - on the command line)- so if I am missing the bigger picture here - feel free to put me in my place.
The main cause for rejection is that your reverse DNS probably isn't set up properly, and that in turn is because it's generally in your ISP's control. If your domain is example.com, but your IP reverse maps to your.isp.com, a lot of mail servers will reject you as spam.
Ask you ISP is they will set the reverse to your domain.
I don't use sendmail, but in postfix, just set the relay_host to point to the smtp server, and
I have a domain name, which is hosted for the purposes of email by my email provider - who supplies pop3 mail boxes.
The machine I am configuring is not directly on the internet, but behind a NAT and not on a fixed IP address.
In these circumstances - I couldn't setup a reverse DNS pointing to this machine - would that be correct?
All I am after is a way/configuration to get email (with faxes attached) out of this machine (which has Hylafax on), through my email provider (or directly, but it doesn't look possible because of the anti-spam situation) to any email address out-there.
Thanks for that. I've had a quick look and it seems it is what I am after. Looks like the magic word is 'relay'. Shows how you can find a lot of stuff, once you know what to search for. I've been searching all day for sending email using sendmail.
Just thought I would let everybody know how it went. In the end I used Hylafax + Exim (for smtp server and as local command line interface for generating/sending emails) + Dovecot as POP3 server.
I also ended up routing the emails containing faxes exclusively internally - as this way I didn't have to depend on the external email provider and the internet connection being functional to receive faxes - so everything gets delivered through internal network. The email client software (Thunderbird) on the LAN connect directly through POP to the local Hylafax server machine and download the emails containing faxes as attachments.
I know I could have gotten away with a simpler setup (possibly using something like sSmtp to send directly to the email provider/isp's smtp server) - but I used it as an opportunity to delve into and learn about setting up Exim and Dovecot - and even setting up TLS/SSL encryption for SMTP and POP3 connections. It all works wonderfully in the end.
And I finally done what I dreaded and avoided for a long time - setting up an email server for the first time :-)
Any excuse to learn something new (and part with some sleep in the process).