LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 06-24-2012, 10:06 PM   #1
nbodewitz
LQ Newbie
 
Registered: Jun 2012
Location: California
Distribution: CentOS, Arch
Posts: 13

Rep: Reputation: Disabled
Command Line Program to send an Email


Hello Everyone,
I am running a server at home. I need to have the server send an email everyday so i can get updated information no matter where i am at. I have tried using sendmail and mail but neither successfully send my email. I have followed various tutorials and can't seem to figure out what is wrong. All of the mails appear in the Que the ones destined for Gmail say connection timed out, the ones for yahoo do not have any status. Any ideas, I do not really need a complicated server setup as I only need it to send me one email once a day.

Thanks in advance,
Nick
 
Old 06-25-2012, 01:08 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

welcome to LQ.

One thing that is not clear here is what mta you are really using. You say "sendmail" but on most systems, although there may be a "sendmail" command (probably /usr/sbin/sendmail), some other package is being used as the mta. Eg. postfix, exim, msmtp etc.

Related to this is what distro you are running. Most distros should come with a "default" mta, unless you have special requirements, or experience running some other mta you should probably stick to whatever the default is.

Finally, in order to get specific help, it is best to provide specific information. These include the distro and mta you are using (as discussed above), how you have configured your mta, and the *exact* error messages (cut-paste of log files and terminal ouputs).


Evo2.
 
Old 06-25-2012, 01:27 AM   #3
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi,

I will add to evo2 's post this.

If you're at home setting up the mail server then you need to have a fixed IP address and a domain registered. Otherwise it happens what you have experienced, that mail is queued and not delivered.

If you don't have that, then you have the options to setup email to be sent through your ISP's mail server, like:
- relay through google
- postfix relay smtp
- How To Relay Email On A Postfix Server

and that's just some examples of setup.

good luck
 
Old 06-25-2012, 03:01 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Originally Posted by lithos View Post
If you're at home setting up the mail server then you need to have a fixed IP address and a domain registered. Otherwise it happens what you have experienced, that mail is queued and not delivered.
Actually this is not strictly true. For many years I used a local mta on my laptop that always had a random IP address assigned by whatever dhcp server was on the network I happened to be connected to at the time. However, some smtp servers will not accept mail if they cannot establish a reverse connection to the smtp of the sending server (sorry I don't recall what this is actually called). IIRC the mail would appear to be sent and then just be silently dropped by the destination smtp server: this caused all sorts of problems.

So, a few years ago I switched to configuring the smtp servers on my machines to using a smarthost (as described in your links).

Evo2.
 
Old 06-25-2012, 12:21 PM   #5
nbodewitz
LQ Newbie
 
Registered: Jun 2012
Location: California
Distribution: CentOS, Arch
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thanks for the replies,
Evo2, I have only installed the Sendmail server so far as that is what most of the tutorials have shown, If I need to setup more I will. The Server is a Backup server I have running at home that pulls Backups from our website daily. I am in the process of setting up a script that will email me my external ip address to my gmail daily while it is on pulling backups so I can use WOL and Proxy services that I am going to setup on the Server. So the email is not very integral to anyone but myself I just need it to Email me once a day. I am going to try it via the relay method mentioned.

Thanks for the Info,
Nick
 
Old 06-25-2012, 02:54 PM   #6
scandalist
Member
 
Registered: Apr 2011
Posts: 31

Rep: Reputation: 1
I just recently spent about a week configuring a mail server on my VPS (Postfix, Dovecot, Squirrelmail)

I can tell you that I ran into a lot of problems trying to send and receive mail with only my public IP address. It was when I finally transferred my authorative DNS zone from my previous hosting provider to my VPS that these problems smoothed out.

In your case, if you don't want to pay for a domain at least sign up for a dynamic DNS service, install Bind and configure an MX record for your mail server. (Although Bind may be a little overkill. Maybe someone can suggest a lightweight alternative for your purposes.)

Evo2 mentioned that some mail servers will not accept mail if they cannot perform a reverse DNS query. Meaning if your IP address does not resolve to a domain, your hosed. I believe there is some truth in that.

Good luck
 
1 members found this post helpful.
Old 06-25-2012, 05:26 PM   #7
nbodewitz
LQ Newbie
 
Registered: Jun 2012
Location: California
Distribution: CentOS, Arch
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thanks for the Replies,
Yeah I will try a relay once I get home, eventually I may get a registered domain name but seeing as I only need it to send myself an email it is not worth it right now.

Thanks,
Nick
 
Old 06-25-2012, 07:48 PM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
If you have a relay host (that is what you normally would set as outgoing mail server on your client) use the sendEmail program. Note the program name is sendEmail but your distro might call both the package and the program sendemail. Try the alternate if one of the two doesn't work.

sendEmail is strictly an e-mail client, which executes exactly one command. If you have a relay host it will work. If you don't, it depends. There are a dozen of options including password authentication, cc, bcc, attachments etc.

jlinkels
 
Old 06-28-2012, 09:07 AM   #9
bobbrandt
LQ Newbie
 
Registered: Sep 2006
Posts: 23

Rep: Reputation: 0
I have used mailx in the past for this type of task. It will default to using the local MTA on the server, but you can force it to use an external SMTP server. Look up mailx and gmail as I am sure I recently saw a tutorial on how to mailx to send mail to gmail using your google username and password as well.

Bob
 
Old 07-17-2012, 12:06 PM   #10
nbodewitz
LQ Newbie
 
Registered: Jun 2012
Location: California
Distribution: CentOS, Arch
Posts: 13

Original Poster
Rep: Reputation: Disabled
Hey Everyone,
I did get this to work using the gmail relay with Postfix.
https://www.zulius.com/how-to/set-up...tp-relay-host/

The only problem now is that in a cron job the email that shows up is an error but when I execute the script manually it works fine.

Thanks
Nick
 
Old 07-17-2012, 02:45 PM   #11
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi,

perhaps the paths you set up in crontab are not the same as in your shell when you execute the script.
So it is always advisable to use full pathnames within the script, so that it can be ran.

for example:
Code:
$ ntpq -p

may not be the same as:

$ /usr/sbin/ntpq -p
which in first case may not execute, because of the PATH defined in the shell of the user (ie. "root" user can have different paths than "joe")



It may help if you would post the script you are running (with output) and the output of "cron email" job.
 
  


Reply



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
[SOLVED] How to send email from command line? dbrazeau Linux - Newbie 18 03-09-2011 11:21 AM
Send email from command line markotitel Linux - Newbie 4 10-26-2009 08:41 AM
send email from command line djionel82 Programming 6 11-29-2005 12:12 AM
trying to send internet email from a command line...is it possible rutman Linux - Newbie 8 06-26-2004 02:19 AM
Can Pine send an email without from the command line without.. rutman Linux - Newbie 2 06-11-2004 04:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:43 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