You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Zach Cox <zc...@gmail.com> on 2013/02/20 23:23:07 UTC
Send email to mail server on localhost from bash script
Hi - I'm doing some work with Apache James and have it running on my local
development machine, which runs Ubuntu. To simplify testing, I'd like to be
able to send an email to this local James server from a bash script.
I know I can telnet localhost 25 and send it that way, but telnet is
difficult from a script. I've tried using msmtp and that gets the email
into James, but JavaMail is unable to parse the data as a MimeMessage.
I'd like to just find a simple command-line email utility that can send a
well-formed email to my localhost server, without hitting dns or anything.
Does anyone have any good suggestions for doing this?
Thanks,
Zach
Re: Send email to mail server on localhost from bash script
Posted by Zach Cox <zc...@gmail.com>.
Thanks Barry & Eike! Turns out msmtp actually was working for me, but I was
making a stupid mistake in a Mailet.
You did inspire me to roll my own little app using JavaMail which will make
it easy to create some complex emails in the future.
Thanks,
Zach
On Wed, Feb 20, 2013 at 4:48 PM, Eike Kettner <ei...@gmail.com>wrote:
> Hi Zach,
>
> I'm using mutt as mail client and I use it for the purpose you
> describe, too. All you need is a ~/.muttrc file with the required
> stuff. Then this command
>
> mutt -s "my subject" user@localhost < sometext.txt
>
> should work. You can also set a config file explicitely with "mutt -F
> my-other-muttrc ...". The following page gives a better overview:
>
>
> http://go2linux.garron.me/linux/2010/10/how-send-email-command-line-gmail-mutt-789
>
> hth,
> Eike
>
> 2013/2/20 Zach Cox <zc...@gmail.com>:
> > Hi - I'm doing some work with Apache James and have it running on my
> local
> > development machine, which runs Ubuntu. To simplify testing, I'd like to
> be
> > able to send an email to this local James server from a bash script.
> >
> > I know I can telnet localhost 25 and send it that way, but telnet is
> > difficult from a script. I've tried using msmtp and that gets the email
> > into James, but JavaMail is unable to parse the data as a MimeMessage.
> >
> > I'd like to just find a simple command-line email utility that can send a
> > well-formed email to my localhost server, without hitting dns or
> anything.
> >
> > Does anyone have any good suggestions for doing this?
> >
> > Thanks,
> > Zach
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>
Re: Send email to mail server on localhost from bash script
Posted by Eike Kettner <ei...@gmail.com>.
Hi Zach,
I'm using mutt as mail client and I use it for the purpose you
describe, too. All you need is a ~/.muttrc file with the required
stuff. Then this command
mutt -s "my subject" user@localhost < sometext.txt
should work. You can also set a config file explicitely with "mutt -F
my-other-muttrc ...". The following page gives a better overview:
http://go2linux.garron.me/linux/2010/10/how-send-email-command-line-gmail-mutt-789
hth,
Eike
2013/2/20 Zach Cox <zc...@gmail.com>:
> Hi - I'm doing some work with Apache James and have it running on my local
> development machine, which runs Ubuntu. To simplify testing, I'd like to be
> able to send an email to this local James server from a bash script.
>
> I know I can telnet localhost 25 and send it that way, but telnet is
> difficult from a script. I've tried using msmtp and that gets the email
> into James, but JavaMail is unable to parse the data as a MimeMessage.
>
> I'd like to just find a simple command-line email utility that can send a
> well-formed email to my localhost server, without hitting dns or anything.
>
> Does anyone have any good suggestions for doing this?
>
> Thanks,
> Zach
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Send email to mail server on localhost from bash script
Posted by Barry Lai <bl...@getabine.com>.
Here's perl I use:
use Net::SMTP;
my $to = "someuser@mydomain.com";
my $from = "somebody@somedomain.com";
my $subject = "test message subject";
my $message = "some message body";
#Create a new object with 'new'.
$smtp = Net::SMTP->new("localhost");
$smtp->mail($from);
$smtp->to($to);
#Start the message.
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n"); # done with header
$smtp->datasend($message);
#End the message.
$smtp->dataend();
#Close the connection to your server.
$smtp->quit();
On Wed, Feb 20, 2013 at 5:23 PM, Zach Cox <zc...@gmail.com> wrote:
> Hi - I'm doing some work with Apache James and have it running on my local
> development machine, which runs Ubuntu. To simplify testing, I'd like to be
> able to send an email to this local James server from a bash script.
>
> I know I can telnet localhost 25 and send it that way, but telnet is
> difficult from a script. I've tried using msmtp and that gets the email
> into James, but JavaMail is unable to parse the data as a MimeMessage.
>
> I'd like to just find a simple command-line email utility that can send a
> well-formed email to my localhost server, without hitting dns or anything.
>
> Does anyone have any good suggestions for doing this?
>
> Thanks,
> Zach
>
--
Barry Lai
Software Engineer, Abine