Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I can send email from my gmail account by ssmtp in Linux now. But how can I attach files to the email?

share|improve this question

1 Answer

up vote 6 down vote accepted

To send an attachment, you need to encode the message using MIME.

You could use Mutt

mutt -s SUBJECT -a ATTACHMENT_FILE EMAIL_ADDRESS < MESSAGE_FILE

or mpack

mpack -s SUBJECT -D MESSAGE_FILE ATTACHMENT_FILE EMAIL_ADDRESS

See also:

share|improve this answer
Thanks. So is that to say that it is NOT possible to send an attachment by ssmtp alone? – deepsky Jul 26 '12 at 15:26
3  
It's possible, but you'd have to generate all the MIME headers somehow. Why do you need to only use ssmtp? If ssmtp provides /usr/lib/sendmail or /usr/sbin/sendmail, any local mail program should be able to send via ssmtp. – Mikel Jul 26 '12 at 15:34
@deepsky ssmtp is not a user interface. It's an MTA (mail transport agent), which is infrastructure meant to be accessed via an MUA (mail user agent, also known as a "mailreader"). It's sort of impressive that you were able to wrangle ssmtp by yourself without an MUA, but it's not a reasonable method of doing things. It's a good network-debugging skill you've learned though! – Alan Curry Jul 27 '12 at 4:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.