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?

  • 1
    OS has nothing to do with it. GMail in a web browser works the same across all OSes and even if you use a email client software, it depends on the software used, not the OS. Many, like Thunderbird, are available for all OS families. –  Aug 30 '18 at 20:33
  • Could you clarify pls, how MongoDB and zip is related to sending attachment via email ??? Attachment is attachment. Look online for `msmtp` and `mutt`... – Alex Aug 31 '18 at 01:42
  • Actually i need to send a file in a zip file via email in unix, Which is solved by using mutt ==>Mutt is a small but very powerful text-based mail client for Unix operating systems – Ishwar Chandra Tiwari Aug 31 '18 at 14:22
  • @Alex ah thanks it work you can put in answer if you want to so i can select it, ==>mutt solved my problem. – Ishwar Chandra Tiwari Aug 31 '18 at 14:26
  • Posted full solution as answer – Alex Aug 31 '18 at 17:04

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           [email protected]
user           [email protected]
password       [email protected]

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 [email protected]
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'))" \
       [email protected] 

Alex
  • 6,187
  • 1
  • 16
  • 25