nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Mailing from my Local Linux system

This is a discussion on Mailing from my Local Linux system within the Linux software forums, part of the Linux Getting Started category; I have never configured "mail" on linux. Now I need to use a script to email me a report once ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-11-2006, 04:53 PM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default Mailing from my Local Linux system

I have never configured "mail" on linux. Now I need to use a script to email me a report once every day. Till now, I have been using Thunderbird and use the SMTP /IMAP server in my campus to send and receive mail

I want to know how to use the mail command from the command line to send mails. I mean, I have an email account in a server mail.mydomain.net and how do I configure "mail" to use it. The smtp port is on port 991.

I have tried to just use this:

Code:
mail -s "test mail" ricc@yahoo.com < ~/outputfile
and try to configure postfix daemon in my PC to relay it to my mail server as said by Tom in this post:

http://forum.cyberciti.biz/mail-serv...hlight=postfix

My postfix daemon can ping the server and can telnet to the said port. But the /var/log/mail indicates connection timeout.

I want to know how to enable mailing and also if I need to use a local SMTP server on my PC. I would like to avoid using this becoz I already have an account on my main email server and would like to use that.

ricc
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-12-2006, 10:55 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 564
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

So you want to use local workstations mail system to forward mail via mail.mydomain.net?
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #3 (permalink)  
Old 09-12-2006, 01:31 PM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default

My primary objective is to have my system mail the log file, that a script creates, to an external email id - ricc@yahoo.com.

I already have a campus-wide email id ( ricc@mydomain.net ) in my campus email server.

What I want is, to be able to send this log file as mail to ricc@yahoo.com from my account ricc@mydomain.net.

I am not sure if I have been able to make you all understand what I want.

But if you have not understood what is my objective, I would like to say that I want to know how to use simple email from the command line. That means...I would like to use my email account in the email server to send a file from my local system ( mainly from the command line ).

I dont want to use something like root@mypc.mydomain.net to send messages ( which unfortunately, I have not been able to do so also)

ricc
Reply With Quote
  #4 (permalink)  
Old 09-13-2006, 03:04 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 481
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Quote:
I want to know how to enable mailing and also if I need to use a local SMTP server on my PC. I would like to avoid using this becoz I already have an account on my main email server and would like to use that.
Ok, it seems that I'm getting your problem?

First, you need working mail null client (which will forward mail from local workstation/server to real mail server). In your case all you need to do is tell your mail server to route mail using your mailserver. For example add following line to sendmail /etc/mail/mailertable
Code:
127.0.0.1	smtp:p5smtpout.mymailserver.net
127.0.0.2 Above line force to use existing mail server called
p5smtpout.mymailserver.net

For postfix edit /etc/postfix/main.cf and add/append line:
Code:
relayhost = p5smtpout.mymailserver.net
Restart the server. Now mail will be forwarded to p5smtpout.mymailserver.net. Please note that to avoid spam problem many mail servers are (p5smtpout.mymailserver.net) configured to reject mail. So make sure your server accept the mail.
Reply With Quote
  #5 (permalink)  
Old 09-13-2006, 10:45 AM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default

Thanks monk,

I found something that I want to share. I have found that we can configure mail (or nail) to use .mailrc file in my home directory to use my campus email server to send and receive mail.

Here it is something that I found in this site:
http://<br /> <br /> <a href="http...<br /> <br />

I have input my imap and smtp server settings and the password in the file:

Code:
set folder=imap://ricc@172.16.0.201
set smtp=smtp://172.16.0.201
set from="ricc@mydomain.net( RICC )"
#set smtp_use_starttls
set smtp-auth=login
set smtp-auth-user=ricc
set smtp-auth-password=password
After this, when I compose a message and send it from the command line like this:

Code:
mypc:~ # mail -v -s "test msg" ricc@yahoo.com <~/testmail
then it shows:

Code:
Resolving host 172.16.0.201 . . . done.
Connecting to 172.16.0.201 . . . connected.
220 mx1.mydomain.net ESMTP
>>> EHLO mypc.mydomain.net
250-c2a.mydomain.net
250-PIPELINING
250-SIZE 15000000
250-ETRN
250-STARTTLS
250 8BITMIME
>>> AUTH LOGIN
530 Must issue a STARTTLS command first
smtp-server: 530 Must issue a STARTTLS command first
. . . message not sent.
This indicates that I have succeeded in trying to send the mail usng the account that I have in my campus email server. But another problem that I encounter is that it says :

Code:
 530 Must issue a STARTTLS command first
I dont know how to enable that. I have tried to insert a line in the .mailrc file :

Code:
 set smtp_use_starttls
But this has no effect. Perhaps the syntax is different. This has been commented after it failed too. Can anybody help.

ricc[/code]
Reply With Quote
  #6 (permalink)  
Old 09-15-2006, 02:00 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 564
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Few years back i was using something as follows in my shell script:
Code:
MAILRC=/dev/null from=you@domain.com smtp=smtp.mail.com \
                 smtp-auth-user=smtpUser smtp-auth-password=smptUser \
                 smtp-auth=login nail -n -s "My Subject" \
                 -a /tmp/somefile.tar.gz outside@gmail.com < /tmp/message.tmp.out
Btw, there is no such option called - set smtp_use_starttls try smtp-use-starttls
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #7 (permalink)  
Old 09-15-2006, 02:08 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 564
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Your config should be as follows:

Code:
vi .mailrc
Add code:
Code:
account myisp {
set folder=imap://ricc@172.16.0.201 
set smtp=smtp://172.16.0.201
set from="ricc@mydomain.net( RICC )" 
set smtp-use-starttls 
set smtp-auth=login 
set smtp-auth-user=ricc 
set smtp-auth-password=password
}
To run type command:
Code:
nail -A myisp -v -s 'test' out@gmail.com
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #8 (permalink)  
Old 09-15-2006, 10:59 AM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default

Thanks rocky,

I have done as you said. I am getting a new error

Code:
ricc@mypc:~> nail -v -s 'test' ricc@yahoo.com
Test Messages
EOT
Resolving host 172.16.0.201 . . . done.
Connecting to 172.16.0.201 . . . connected.
220 mx1.mydomain.net ESMTP
No SSL support compiled in.
. . . message not sent.
As per the .mailrc config file that you submitted, I have done as you said. But it gave an error :

Code:
Unknown command: "}"
I removed the account myisp function and the curly braces.

But I think the error "No SSL support compiled in" is due to SSL support not compiled into the nail program.

Pls help me.

ricc
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
creating a group mailing list on linux sunguru The Hangout 1 06-07-2008 02:49 PM
Error while logging in the linux system vaibhav.kanchan Getting started tutorials 2 07-19-2007 09:27 PM
code for connecting two linux system narasimha.reddygnv Shell scripting 1 03-27-2007 10:23 AM
Linux krefilld process and what is it doing on my system? sweta Linux software 1 08-31-2006 01:16 AM
linux gather system information Linux software 3 01-24-2006 06:45 PM


All times are GMT +5.5. The time now is 04:21 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36