The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   how to send mail? (http://hintsforums.macworld.com/showthread.php?t=88927)

milc 04-24-2008 11:54 AM

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!!

hayne 04-24-2008 12:32 PM

What version of OS X do you have?
Sending mail messages via the 'mail' command works fine in 10.4.11

milc 04-24-2008 12:35 PM

I do have 10.4.11....

any idea??

tlarkin 04-24-2008 12:43 PM

I think this is how it works...

/path/to/command -options | mail email@domain.com -s "subject"
some text
some more text
.

hayne 04-24-2008 12:44 PM

Look at the log file "/var/log/mail.log"
You can do this with any text editor, or with the "Console" application.

hayne 04-24-2008 12:47 PM

Quote:

Originally Posted by tlarkin (Post 466087)
I think this is how it works...

/path/to/command -options | mail email@domain.com -s "subject"
some text
some more text
.

No - the "-s" option has to come before the address.

milc 04-24-2008 12:54 PM

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)

ashevin 04-24-2008 12:55 PM

The first thing I'd try is to send mail to yourself:

e.g.

Code:

echo "Hi!' | mail -s test ashevin
Just insert your own (short) name where I placed my own.

tlarkin 04-24-2008 01:25 PM

Quote:

Originally Posted by hayne (Post 466089)
No - the "-s" option has to come before the address.

Ah, yeah sorry my syntax was off. If you use the mail command in terminal and not in a script it should go into interactive mode and you just keep typing and when you are done, hit period . then enter, and it should execute the mail.

milc 04-24-2008 01:47 PM

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!!

wdympcf 04-24-2008 01:53 PM

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.

hayne 04-24-2008 02:42 PM

Quote:

Originally Posted by milc (Post 466091)
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)

It seems like 'postfix' (the program that sends the mail onwards) is trying to send it via Google's SMTP server.
Many (most?) ISPs don't allow you to send mail except via their own SMTP server.

tlarkin 04-24-2008 03:51 PM

I just did it from terminal exactly how I described and it worked, but my spam filter flagged it as spam.

milc 04-25-2008 08:37 AM

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...

acme.mail.order 04-25-2008 10:18 AM

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).

wdympcf 04-25-2008 01:04 PM

Quote:

but what is verbose mode?
how can you do that what you told me to do, wdympcf??
Try typing this, although based on what you posted above, I'm not sure that it is going to provide any more information:

Code:

ls | mail -v -s "test" ydjeho@gmail.com > test_mail.txt
When you say that nothing happens, what do you mean specifically? Does the Terminal return to a new prompt, or does it hang indefinitely doing nothing?

I 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?

hayne 04-25-2008 01:22 PM

Quote:

Originally Posted by wdympcf (Post 466319)
hayne, can you specify how to change the outgoing mail server in postfix?

Sorry - I have no experience with this.
(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.

milc 04-26-2008 07:55 AM

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....)

LingaringBell 04-27-2008 03:32 AM

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.

acme.mail.order 04-27-2008 03:42 AM

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.

wdympcf 04-28-2008 07:46 PM

Quote:

Sorry - I have no experience with this.
(I don't usually send mail from the command-line.)
Me either. However, it would appear that it is not that crucial to the OP that they be able to send mail from the Terminal....

mnewman 04-28-2008 09:54 PM

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=550
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
smtpd_sender_restrictions=check_sender_access hash:/etc/postfix/access
inet_interfaces=all
inet_protocols=all
message_size_limit=5000000
mailbox_size_limit=51200000
mynetworks_style=subnet
##myorigin=mydomain.com
myhostname=mydomain.com
relayhost=smtp.myisp.com
local_recipient_maps=
luser_relay=myshortname
smtp_generic_maps = hash:/etc/postfix/generic
virtual_alias_maps = hash:/etc/postfix/virtual

Oddly, sometimes I have to comment out the "relayhost" line. My ISP is inconsistent about how it treats mail originating from a dynamic IP address.

Here'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)
Good luck. Every time Apple does an OS/X update things change and I have to tweek postfix to get it working again.

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.