1

I have been using filezilla to import/export some data from server.

How to send a file in a zip file via email in unix?

Ishwar
  • 111

1 Answers1

1

You can use two Ubuntu's console's packages: msmtp and mutt to send email attachment.

Install packages :

sudo apt-get install msmtp mutt ca-certificates

Configure msmtp to use existing email as outgoing email: (example for gmail account)

#!/bin/sh

echo '# Default values for all accounts.
defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        ~/.local/msmtp.log

# Gmail
account        gmail
host           smtp.gmail.com
port           587
from           user@gmail.com
user           user@gmail.com
password       SuperSecretPassword4user@gmail.com

account default : gmail
` >~/.msmtprc

Prepare default mutt setting:

#!/bin/sh

[ -f '~/.muttrc' ] || {
  echo '
set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname="Display Name"
set from=user@gmail.com
set envelope_from=yes
' > ~/.muttrc
}

Send email with attachment with help of mutt:

echo 'Please see attached MongoDB database...' |
  mutt -a MongoDB.zip \
       -s "Zipped MongoDB attachment ($(date '+%Y-%m-%dT%H:%M:%S'))" \
       someRecipient@example.com 

Alex
  • 6,375