VMware Cloud Community
mondorescue
Contributor
Contributor
Jump to solution

How to send an email from vma?

Hi together,

does anybody know how to send an email from vma?

i don't find the command "mail".

Thanks

Timm

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

vMA is a pretty stripped down Linux OS, having said that, it's just LINUX. You can easily install additional packages such as a mail client, one is not included by default.

I've sent mail using Net::SMTP Perl module and you can find many examples on the web or install your own perferred mail client.

View solution in original post

0 Kudos
5 Replies
firestartah
Virtuoso
Virtuoso
Jump to solution

Hi

Unfortunately I don't think there is a way to send emails via the vma. I've just had a look through my VMA guide and there is no mention of SMTP settings or mail to that matter either. You can send mails via PowerCLI though as another path you could take?

Gregg

If you found this or other information useful, please consider awarding points for "Correct" or "Helpful". Gregg http://thesaffageek.co.uk
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

vMA is a pretty stripped down Linux OS, having said that, it's just LINUX. You can easily install additional packages such as a mail client, one is not included by default.

I've sent mail using Net::SMTP Perl module and you can find many examples on the web or install your own perferred mail client.

0 Kudos
gettyless
Enthusiast
Enthusiast
Jump to solution

By default, on my VMA (5.0.0.0 Build 472630), I can install mailx from the stock opensuse repository. I found it through zypper:

vma1:~ # zypper search mail
New repository or package signing key received:
Key ID: B88B2FD43DBDC284
Key Name: openSUSE Project Signing Key <opensuse@opensuse.org>
Key Fingerprint: 22C07BA534178CD02EFE22AAB88B2FD43DBDC284
Repository: opensuse
Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): a
Building repository 'opensuse' cache [done]
Loading repository data...
Reading installed packages...
S | Name                                 | Summary                                                                 | Type  
--+--------------------------------------+-------------------------------------------------------------------------+--------
  | ant-javamail                         | Optional javamail tasks for ant                                         | package
  | archivemail                          | Tool for archiving and compressing old email in mailboxes               | package
  | classpathx-mail                      | GNU JavaMail is a free implementation of the JavaMail API specification | package
  | classpathx-mail-javadoc              | GNU JavaMail(tm)                                                        | package
  | claws-mail                           | A lightweight and highly configurable email client                      | package
  | claws-mail-devel                     | A lightweight and highly configurable email client                      | package
  | claws-mail-extra-plugins             | Plugins for Claws Mail                                                  | package
  | claws-mail-extra-plugins-devel       | Plugins for Claws Mail                                                  | package
  | claws-mail-extra-plugins-lang        | Languages for package claws-mail-extra-plugins                          | package
  | claws-mail-lang                      | Languages for package claws-mail                                        | package
  | enigmail                             | OpenPGP addon for Thunderbird and SeaMonkey                             | package
  | fetchmail                            | Full-Featured POP and IMAP Mail Retrieval Daemon                        | package
  | fetchmailconf                        | Fetchmail Configuration Utility                                         | package
  | geronimo-javamail-1_3_1-api          | Geronimo J2EE server J2EE specifications                                | package
  | geronimo-javamail-1_4-api            | Geronimo J2EE server J2EE specifications                                | package
  | git-email                            | Git tools for sending email                                             | package
  | gnome-gmail-notifier                 | Gmail Notifier for GNOME                                                | package
  | gnome-gmail-notifier-lang            | Languages for package gnome-gmail-notifier                              | package
  | grepmail                             | Search Mailboxes for a Particular E-Mail                                | package
  | kmail                                | Mail Client                                                             | package
  | libreoffice-mailmerge                | Mail Merge Functionality for LibreOffice                                | package
  | mail-notification                    | Status icon checking for new mail                                       | package
  | mail-notification-lang               | Languages for package mail-notification                                 | package
  | mail_server                          | Mail and News Server                                                    | pattern
  | mailman                              | The GNU Mailing List Manager                                            | package
  | mailsync                             | The Mail Sync Tool                                                      | package
  | mailx                                | A MIME-Capable Implementation of the mailx Command                      | package
i | metamail                             | MIME Mail Handler                                                       | package
  | patch2mail                           | Patch notification via mail                                             | package
  | patterns-openSUSE-mail_server        | Meta package for pattern mail_server                                    | package
  | perl-Email-Address                   | RFC 2822 Address Parsing and Creation                                   | package
  | perl-Email-Date-Format               | Produce RFC 2822 date strings                                           | package
  | perl-Mail-DKIM                       | Signs/verifies Internet mail with DKIM/DomainKey signatures             | package
  | perl-Mail-Mbox-MessageParser         | A fast and simple mbox folder reader                                    | package
  | perl-Mail-SPF                        | An object-oriented implementation of Sender Policy Framework            | package
  | perl-Mail-Sendmail                   | Simple platform independent mailer                                      | package
  | perl-Mail-SpamAssassin               | Perl Modules For Using Spamassassin Within An Own Perl Script           | package
  | perl-Mail-SpamAssassin-Plugin-iXhash | The iXhash plugin for SpamAssassin                                      | package
  | perl-MailTools                       | a set of perl modules related to mail applications                      | package
  | php5-pear-Mail                       | Multiple interfaces for sending emails                                  | package
  | php5-pear-Mail_Mime                  | Mail_Mime provides classes to create mime messages                      | package
  | php5-pear-Mail_mimeDecode            | Decode mime messages                                                    | package
  | pilot-mailsync                       | An e-mail Synchronization Program for Palm OS-based Organisers          | package
  | pilot-mailsync-gnome-pilot           | GNOME Pilot Plug-in for e-mail Synchronization                          | package
  | pilot-mailsync-jpilot                | J-Pilot Plug-in for e-mail Synchronization                              | package
i | procmail                             | A program for local e-mail delivery                                     | package
  | rmail                                | Rmail of the BSD Sendmail                                               | package
  | rubygem-actionmailer                 | Mail service classes for Ruby on Rails                                  | package
  | rubygem-actionmailer-2_3             | Service layer for easy email delivery and testing                       | package
  | rubygem-actionmailer-2_3-doc         | RDoc documentation for actionmailer                                     | package
  | rubygem-actionmailer-2_3-testsuite   | Test suite for actionmailer                                             | package
i | sendmail                             | BSD Sendmail                                                            | package
  | sendmail-devel                       | BSD Sendmail Development Kit                                            | package
  | webyast-mail-ui                      | WebYaST - Mail Settings UI                                              | package
  | webyast-mail-ui-testsuite            | Testsuite for webyast-mail-ui package                                   | package
  | webyast-mail-ws                      | WebYaST - system mail settings service                                  | package
  | webyast-mail-ws-testsuite            | Testsuite for webyast-mail-ws package                                   | package
  | xfce4-panel-plugin-mailwatch         | Versatile mail checking plugin for the Xfce panel                       | package
  | yast2-mail                           | YaST2 - Mail Configuration                                              | package
  | yast2-mail-plugins                   | YaST2 - Users/Group Plugins for the mail delivery configuration         | package
vma1:~ # zypper install mailx
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following NEW packages are going to be installed:
  libopenssl1_0_0 mailx
The following package is recommended, but will not be installed:
  exim
The following packages are not supported by their vendor:
  libopenssl1_0_0 mailx
2 new packages to install.
Overall download size: 1.0 MiB. After the operation, additional 2.8 MiB will be used.
Continue? [y/n/?] (y): y
Retrieving package libopenssl1_0_0-1.0.0c-17.1.x86_64 (1/2), 723.0 KiB (2.3 MiB unpacked)
Retrieving: libopenssl1_0_0-1.0.0c-17.1.x86_64.rpm [done (132.4 KiB/s)]
Installing: libopenssl1_0_0-1.0.0c-17.1 [done]
Retrieving package mailx-12.2-155.5.x86_64 (2/2), 301.0 KiB (519.0 KiB unpacked)
Retrieving: mailx-12.2-155.5.x86_64.rpm [done (81.2 KiB/s)]
Installing: mailx-12.2-155.5 [done]

And to verify this worked and showed up in my inbox:

echo "asdfasdf" | mail gettyless@xxxxx.com

Jan  5 22:39:30 vma1 sendmail[30048]: q05MdRq0030046: to=<gettyless@xxxxx.com>, ctladdr=<root@vma1.xxxxxx.com> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120476, relay=xxxx.xxxxx.com. [10.10.10.19], dsn=2.0.0, stat=Sent (q05MfMq9003386 Message accepted for delivery)

^C

jce201110141
Contributor
Contributor
Jump to solution

Update: Apparently, I downloaded an old version of vMA, so this is for vMA 4. I'm working on vMA 5 right now...

I ran into this same problem. None of my VMs have network-accessable SMTP servers, so my vMA VM needs to send directly to the recipient's server, which should be fine in most cases. First I tried looking for sendmail, postfix, sendEmail and other lightweight SMTP applications, but there aren't any. They either require an SMTP relay to talk to, or require lots of RPMs, or RPMs I wasn't able to find easily. The RHEL release that vMA 5 is built upon is spectacularly old, so I had to hunt around for RPMs. I won't say this is the best solution, but it does work. This is what I did:

1. SSH into the vMA VM (I used WinSCP).

2. Get the following RPMs and transfer them over:

perl-IO-Socket-SSL-1.44-1.el5.rfx.noarch.rpm

perl-Net-SMTP-SSL-1.01-1.el5.rf.noarch.rpm

perl-Net-SSLeay-1.36-1.el5.rfx.x86_64.rpm

I got mine from "random" sites (e.g. http://pkgs.repoforge.org/perl-Net-SSLeay/)

3. Install them all via sudo rpm -i *rpm

4. Create a Perl script to send mail. This is probably my third Perl script ever written. It has no error checking, and generally shouldn't be used, but it does work under perfect conditions. I intentionally broke it, so you'll have to uncomment and modify one line for it to work:

#!/usr/bin/perl -w

use strict;
use Getopt::Std;
use Net::SMTP;

my %options = ();
getopts("d:f:s:", \%options);

my @tmp = split(/@/, $options{f});
my $destinationDomain = $tmp[1];

my @mxServers = `dig +short mx $destinationDomain | sort -n | awk '{print \$2}'`;
my $mxServer = $mxServers[0];

chomp(@mxServers);

chop(@mxServers);

my $mxServer = $mxServers[0];

#my $smtp = Net::SMTP->new($mxServer, Debug => 1) || die "Error: $!";
$smtp->mail($options{f});
$smtp->recipient($options{d});

$smtp->data;
$smtp->datasend("From: $options{f}\n");
$smtp->datasend("To: $options{d}\n");
$smtp->datasend("Subject: $options{s}\n");
$smtp->datasend("\n");

while (defined(my $line = <STDIN>)) {
    $smtp->datasend($line);
}

$smtp->dataend;
$smtp->quit;

Good luck!

Josh

0 Kudos
andybailey
Contributor
Contributor
Jump to solution

Josh - very interested to see if you have managed to get email to work in vMA 5? I have tried sendEmail and ssmtp in 5 but no joy so far. Thanks.

0 Kudos