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?

5
  • 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.
    – user931000
    Commented Aug 30, 2018 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
    Commented Aug 31, 2018 at 1: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 Commented Aug 31, 2018 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. Commented Aug 31, 2018 at 14:26
  • Posted full solution as answer
    – Alex
    Commented Aug 31, 2018 at 17:04

1 Answer 1

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] 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .