![]() |
how to send mail?
hi,
I'm learning UNix with a book and everything goes fine, except that the mails that I send using terminal never arrive! this should work... ls -l /usr/bin | mail -s "subject" address but when I try this terminal never output any error messages but I never recieve the mail that I should receive... what's the problem?? thanks in advance!! |
What version of OS X do you have?
Sending mail messages via the 'mail' command works fine in 10.4.11 |
I do have 10.4.11....
any idea?? |
I think this is how it works...
/path/to/command -options | mail email@domain.com -s "subject" some text some more text . |
Look at the log file "/var/log/mail.log"
You can do this with any text editor, or with the "Console" application. |
Quote:
|
here's what my console shows...
Apr 24 18:43:40 djeho-youns-computer postfix/master[254]: daemon started -- version 2.1.5 Apr 24 18:43:41 djeho-youns-computer postfix/pickup[255]: 964C12A5573: uid=501 from=<djehoyoun> Apr 24 18:43:41 djeho-youns-computer postfix/cleanup[256]: 964C12A5573: message-id=<20080424164340.964C12A5573@djeho-youns-computer.local> Apr 24 18:43:41 djeho-youns-computer postfix/qmgr[258]: 179FD2A4D25: from=<djehoyoun@djeho-youns-computer.local>, size=16358, nrcpt=1 (queue active) Apr 24 18:43:41 djeho-youns-computer postfix/qmgr[258]: 405001709A7: from=<djehoyoun@djeho-youns-computer.local>, size=50223, nrcpt=1 (queue active) Apr 24 18:43:41 djeho-youns-computer postfix/qmgr[258]: 469D2170A82: from=<djehoyoun@djeho-youns-computer.local>, size=467, nrcpt=1 (queue active) Apr 24 18:43:41 djeho-youns-computer postfix/qmgr[258]: 860481709DA: from=<djehoyoun@djeho-youns-computer.local>, size=15162, nrcpt=1 (queue active) Apr 24 18:43:42 djeho-youns-computer postfix/qmgr[258]: 964C12A5573: from=<djehoyoun@djeho-youns-computer.local>, size=519, nrcpt=1 (queue active) Apr 24 18:43:42 djeho-youns-computer postfix/qmgr[258]: BA253170A47: from=<djehoyoun@djeho-youns-computer.local>, size=481, nrcpt=1 (queue active) Apr 24 18:43:42 djeho-youns-computer postfix/qmgr[258]: C7ABF2A4C4A: from=<djehoyoun@djeho-youns-computer.local>, size=2553, nrcpt=1 (queue active) Apr 24 18:44:12 djeho-youns-computer postfix/smtp[259]: connect to gmail-smtp-in.l.google.com[209.85.129.27]: Operation timed out (port 25) Apr 24 18:44:12 djeho-youns-computer postfix/smtp[261]: connect to gmail-smtp-in.l.google.com[72.14.221.27]: Operation timed out (port 25) Apr 24 18:44:12 djeho-youns-computer postfix/smtp[262]: connect to gmail-smtp-in.l.google.com[209.85.129.27]: Operation timed out (port 25) Apr 24 18:44:12 djeho-youns-computer postfix/smtp[263]: connect to gmail-smtp-in.l.google.com[72.14.221.114]: Operation timed out (port 25) Apr 24 18:44:12 djeho-youns-computer postfix/smtp[264]: connect to f.mx.mail.yahoo.com[68.142.202.247]: Operation timed out (port 25) Apr 24 18:44:17 djeho-youns-computer postfix/smtp[260]: connect to gmail-smtp-in.l.google.com[209.85.135.27]: Operation timed out (port 25) |
The first thing I'd try is to send mail to yourself:
e.g. Code:
echo "Hi!' | mail -s test ashevin |
Quote:
|
I've tried to send mail to myself but it doesn't work.
I've did as Tlarkin said but no result.... I'm going crazy!! |
As always, any time a command line tool is not doing what you think it should be doing, you should run it in verbose mode. Set the -v flag and try running the mail command again. Pipe the output into a text file and post it here for us to look at.
|
Quote:
Many (most?) ISPs don't allow you to send mail except via their own SMTP server. |
I just did it from terminal exactly how I described and it worked, but my spam filter flagged it as spam.
|
sorry but I'm very unexperienced...(I've started open Terminal 2 days ago...)
but what is verbose mode? how can you do that what you told me to do, wdympcf?? I've tried this; ls | mail -vs "test" ydjeho@gmail.com and it output; Mail Delivery Status Report will be mailed to <djehoyoun>. then nothing happens as always.... what is ISP or SMPT?? I did nothing to my web connection config. It's totally....uh...normal... and I've checked my spam folder, nothing inside... my macbook is like everyone else's....weird... |
What they are saying above is that it is likely you can do everything correctly but your internet provider will stop it getting to its destination - it gets deleted immediately or has a huge SPAM!! header attached. This is a common anti-spam method that is rather complex to work around (which is entirely the point).
|
Quote:
Code:
ls | mail -v -s "test" ydjeho@gmail.com > test_mail.txtI think hayne is onto something above. You likely need to set your outgoing mail server to your ISP's server. I assume this is something that can be set in postfix, but I am not familiar with it. hayne, can you specify how to change the outgoing mail server in postfix? |
Quote:
(I don't usually send mail from the command-line.) In my test (prompted by this thread), I sent email to myself, using my email address at my ISP. So maybe the email address is used to set a default SMTP server? Try sending email to an email address at your ISP to test this - and if that works, maybe that is sufficient for your needs. As an alternative to using the 'mail' command, I note that it is possible to use AppleScript to send mail via your usual email program (e.g. Apple's Mail.app) - there was a macosxhints article about this. By the way, ISP = Internet Service Provider. I.e. the company that provides your Internet connection. |
thanks for all the replies!
it still doesn't work but if it's a sever side problem, then I think it's ok. i just need to be sure that I do everything correctly. as I do not have mail address from my ISP (I share the connection with people), I can't really test but I think I don't really need to send mail from Terminal. (that will be awsome if it work though....) |
is there a way to change the port terminal uses to send mail? In my experience, ISPs commonly put this restriction only on port 25.
|
It's probably easy to change the port, but to what other port? You would need to know the SMTP listen port of the mail server you are trying to contact. If there's only one it shouldnt be a problem.
|
Quote:
|
It's not easy to get postfix working. As noted above, your ISP may be blocking mail that you try to send. To get this working you will probably have to edit the postfix configuration file: /etc/postfix/main.cf
Here are the lines that I added or modified in my main.cf file: Code:
unknown_local_recipient_reject_code=550Here's what the mail.log looks like when mail has been sent successfully: Code:
Apr 29 08:46:50 Smooch postfix/smtp[7241]: 7D99B8232F8: to=<me@mac.com>, relay=smtp.myisp.com[2xx.xxx.xxx.xxx]:25, delay=4.3, delays=0.32/0.08/3.6/0.33, dsn=2.0.0, status=sent (250 ok: Message 140916886 accepted)As for why someone would want to send e-mail from the command line: I use it in shell scripts to notify me by e-mail when tasks have been done. For example, I have Carbon Copy Cloner send me e-mail when a backup has been done. |
| All times are GMT -5. The time now is 10:17 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.