![]() |
Send an email inside Terminal
Is there a way that I can create and send an email from within Terminal? Will I need to have postfix or anything turned on for this to work or can is there an option to define the smtp server?
|
Do you mean with a script? If so you can use Perl with the Net::SMTP module installed.
Do you mean interactively? If so you can use Pine (install the Fink application and use 'sudo apt-get install pine' would be the quickest...) You will have to define an SMTP server in both method unless you have sendmail configured and running on your box... |
You could certainly telnet into your smtp mail server and send email manually. Instructions are in many places on the 'net, hang on and I'll find one....
Here's one: Telnet - SMTP Commands (sending mail using telnet) Others: Google search: telnet smtp Trevor |
Out of the box I could use,
Quote:
I was blown away. Here's how I think it goes down, but be warned... I don't really know what I'm talking about... By default postfix is loaded as an on-demand service, so calling mail queues your message, and postfix directly contacts gmail (in this case) and attempts to deliver the message (no smtp config done here). I believe that this only works with certain servers (i.e. it works for me with gmail, but I just tested it with yahoo, and so far, no go). Give it a try. If you want full functionality, you can set postfix to run as a daemon, and configure it to talk to your mail server (just don't ask me how yet...I'm still trying to learn). |
Quote:
Quote:
On many unix boxes since forever: mail <address> interactive and scriptable. with no address it reads your mail. Wether mail sent in this (or any other local method) reaches it's destination depends on various intermediate providers and the recipient's spam filters. |
Quote:
The most basic command for doing this is "mail". Use "cat" to pipe your message to mail See man mail. If you do have postfix or sendmail running on the local computer then you can queue the outgoing mail do retries and rewrites and a ton of stuff. "mail" works well inside a script You can also use the "sendmail" command inside a script You can also use telnet to port 25 and type the SMTP protocol directly. Very primitive but a reasonable way to debug a setup for interactive use at the terminal "mail" works but is primitive. Pine and elm are both better |
Quote:
|
Quote:
Whereas I have run into several instances where I prefer (or must use) a command-line web browser, there have never been any where I would prefer a command-line mail client. I used a unix command line e-mail client in 1985/86 for all of my e-mail, and that's recent enough for me. Trevor |
Quote:
|
Quote:
My way is a lot easier than having to setup your own mail server - which is what is running on your OS X box if you can simply use 'mail' to send emails!!! You are having a laugh if you think mail or mailx would just simply work with 'OS X out of the box'! |
Quote:
|
Quote:
|
Quote:
Quote:
I use Thunderbird as the mail application so settings never get inherited down to the system level (as I am assuming this is what is happening here). Sorry for the doubts :) |
Another experiment... just tried mail on another box WITHOUT the Mail app configured... it works! So I am :confused:
It has never worked before because I never used the FQDN and just my username... So I conclude from this experiment that the Unix mail program can get its information from ANY mail client... unless someone can correct me here ;) (Where is the smtp server info held?) |
Quote:
|
I did some further investigation... and tests...
The mail agent on OS X is postfix: http://www.postfix.org/start.html It seems quite smart and needs no configuration! It uses some kind of DNS lookup mechanism to find the MX hosts of the domain you are sending an email to. So if I send an internal email with my FQDN in the email address, then my box would talk to my site's MX hosts and get the message delivered. I have tried to email to external accounts and no email has appear yet! I suspect my local box is talking (or trying to resolve) the MX hosts for these email addresses... and not getting permission to talk to the hosts directly... This could be considered clever or dangerous. Imagine if your Mac got compromised and some spammer floods your site with messages - potential taking your MX hosts down... |
email
hey im logged in as root in the terminal id to know how to send email from someone else is email address to lets say mine for instance lets say i dont know that person's password, i used to know about this i forgot,anybody gotta any idea?
thanks |
Quote:
|
Quote:
"We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility." I think you should log out. :o |
Guys, I'm trying to learn about this as well, but can't figure out the man page. Could someone walk me through the steps needed to create and send a mail message to an address on the internet (say to someone else) from the Terminal?
|
Type:
mail person@example.com and follow the prompts. type . all by itself to finish. Wether the recipient gets the message depends a lot on your ISP's outgoing mail policies. |
I just tried sending a message to my own gmail account. I typed my email address, pressed return, and got the subject line, entered 'test' as subject, pressed return, and entered some more text, then pressed return again, then the . it said "EOT" and the terminal prompt. But there's nothing inside my gmail inbox.
Do I have to configure something else? And why is it so complicated? The book I have doesn't explain this. Are there any other books on UNIX that I could get/you recommend? I'm currently reading "Learning the bash shell' by Newham & Rosenblatt, published by O'Reilly. |
The last sentence of my previous post is your answer. Many ISPs block mail servers other than their own, preventing bot-spam but also preventing you sending out mail.
On the other end, receiving mail servers sometimes block mail from servers that don't have a vaild reverse DNS record (your home machine will definitely not have a valid record). I can't send mail from my home machine either, but I can from my web provider's machine, same command. |
see this hint it configures postfix to send mail via your isp and should work.
|
Straitsfan,
Well if you type "man mail" at the command prompt you'll get a nice summary. mail -s "I'm sending you a letter" someone@example.com < letter.txt That line tells you most of what you need to know. You run the mail command supplying it a subject and the address you want the letter to go to and then redirect in the text. // Tony |
| 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.