# Attach image to email with ssmtp or mailx

## d4mo

What is the best way to do this?

I saw some stuff on uuencode and mimencode.  But I want the image to be visible in a gmail account.

----------

## py-ro

This is how attachments are encoded, they will be visible.

Py

----------

## d4mo

Maybe I am doing it wrong then.  Because when I do it, call I get is a bunch of text in the email and it's not decoded.

Any advice?

----------

## toralf

 *d4mo wrote:*   

> Any advice?

 This works for me:

```
tfoerste@n22 ~/workspace $ cat misc/mymailx.sh

fn_sendmail()

{

        echo "From: <noreply@nowhere> Do not reply to this address

To: tfoerste@localhost

Reply-To: user@other.domain

Subject: test

X-MSMail-Priority: High

Importance: 1

Mime-Version: 1.0

Content-Type: text/plain

 This is a test email ...

 Rgds

"

        [[ -f $ATTACH ]] && uuencode $ATTACH $ATTACH

}

ATTACH=$1

fn_sendmail | /usr/sbin/sendmail -t -O DeliveryMode=i -R hdrs -n

```

----------

