The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Can the shell version of mail send an image? (http://hintsforums.macworld.com/showthread.php?t=112312)

NovaScotian 06-20-2010 07:46 PM

Can the shell version of mail send an image?
 
Can the shell version of mail send an image as an attachment?

acme.mail.order 06-20-2010 08:12 PM

Sure can. Investigate uuencode and RFC 5322. Start with the Wikipedia article MIME (Not Mime - that gets you the Marcel Marceau variety).

SirDice 06-21-2010 02:52 AM

Something like this should do the trick:
Code:

uuencode mypic.jpg mypic.jpg | mail someone@example.com

NovaScotian 06-21-2010 10:10 AM

Thank you; I'm almost there. I'm basically looking for a way to send a picture from my laptop camera without invoking Mail, i.e. in the background. I'll read the man pages for mail to see how to get smtp address and password into it.

tlarkin 06-21-2010 10:48 AM

iAlertU does this exact function. It snaps a pic and then emails it to the designated email address if the computer is disturbed while active. I, off the top of my head, have no idea how to code this. However, perhaps if you take apart the package with something like Pacifist you can see how they do it. It is an open source app.

NovaScotian 06-21-2010 01:06 PM

Yes, I tried it, but it doesn't want to send an email via a webmail account - it wants smtp. If my laptop is nicked, I'm on the road and the only way I can check without it will be at a public terminal.

tlarkin 06-21-2010 01:26 PM

Quote:

Originally Posted by NovaScotian (Post 586899)
Yes, I tried it, but it doesn't want to send an email via a webmail account - it wants smtp. If my laptop is nicked, I'm on the road and the only way I can check without it will be at a public terminal.

Interesting, I never fussed with it too much. It always sent attachments for me but I always used my work email address. I can try it later sometime (time permitting of course) to see if I can get it to work. After the whole web cam scandal at the PA schools I don't really touch web cam stuff much these days.

NovaScotian 06-21-2010 01:30 PM

Follow-up to last post:
 
I was wrong; I just wasn't configuring it properly.

To configure gmail, the mail server is smtp.gmail.com, the port is 465, you check "Use SSL Authentication", the mail server username is the entire account name: user@gmail.com, and you type in the password for your account. If you check the "Email Image" box, it sends the iSight image to the account. Takes about 15 seconds to do it.

mnewman 06-21-2010 08:42 PM

Quote:

Originally Posted by SirDice (Post 586831)
Something like this should do the trick:
Code:

uuencode mypic.jpg mypic.jpg | mail someone@example.com

I tried sending a photo to myself this way. It worked, but mail.app simply shows the attachment as "Mail Attachment". It doesn't extract the file name from uuencode archive and doesn't display the attachment as an embedded image. ("Preview" works as expected.)

On the other hand Gmail (web mail) does display both the correct file name and the embedded image.

NovaScotian 06-21-2010 09:02 PM

Quote:

Originally Posted by mnewman (Post 586954)
I tried sending a photo to myself this way. It worked, but mail.app simply shows the attachment as "Mail Attachment". It doesn't extract the file name from uuencode archive and doesn't display the attachment as an embedded image. ("Preview" works as expected.)

On the other hand Gmail (web mail) does display both the correct file name and the embedded image.

Interesting, because when I tried it in Leopard:

Code:

uuencode pathToMyPic/mypic.jpg mypic.jpg | mail myAccount@gmail.com
it didn't work (I confess to not reading man mail first). Nothing was received even after a wait.

mnewman 06-21-2010 09:18 PM

Did you check the mail queue immediately after executing the command?

Anything in /private/var/log/mail.log?

Code:

Jun 22 08:15:24 Bleach postfix/local[10673]: 340AA31265B3: to=<xxxxx@mgnewman.com>, orig_to=<xxxxx@me.com>, relay=local, delay=0.15, delays=0.09/0.05/0/0.01, dsn=2.0.0, status=sent (forwarded as 4E19631265B4)

NovaScotian 06-22-2010 09:34 AM

Yes: Here's the key line:
Quote:

Jun 21 21:57:15 ACB-G5-7 postfix/smtp[24365]: connect to gmail-smtp-in.l.google.com[74.125.95.27]: Operation timed out (port 25)
repeated for each of my tries.

mnewman 06-22-2010 11:12 AM

Did you setup postfix by editing:

/private/etc/postfix/main.cf

NovaScotian 06-22-2010 11:32 AM

Ahh.... no. Nor will I be able to do so with any understanding (I did look), but thanks for pointing it out.

tw 06-22-2010 02:52 PM

Quote:

Originally Posted by NovaScotian (Post 586882)
Thank you; I'm almost there. I'm basically looking for a way to send a picture from my laptop camera without invoking Mail, i.e. in the background. I'll read the man pages for mail to see how to get smtp address and password into it.

Just as an aside, you can use mail to send an email in the background (I mean, Mail still runs, but it doesn't need to come to the foreground, and won't display anything visible to the user). and what would Marcel Marceau's MIME type be?

NovaScotian 06-22-2010 07:42 PM

Thanks, tw;

Unfortunately, I don't use Mail.app on my Laptop -- it's a long story -- and I want to send the image from there to a gmail account entirely in the background.

Marcel's MIME type was audio/silence, I believe, although it might have been audio/gestures.

mnewman 06-22-2010 09:05 PM

Quote:

Originally Posted by NovaScotian (Post 587018)
Ahh.... no. Nor will I be able to do so with any understanding (I did look), but thanks for pointing it out.

Well, it's not trivial, nor is it rocket science. (I did it and I'm a unix tyro.) Most ISP's balk at relaying mail unless they can figure out who you are and that you have a legitimate domain from which you can send mail. Most of this is done in the interest of spam-bot protection.

For me it was worth the trouble so that I could write some simple scripts to notify me of stuff via e-mail. For example, with Carbon Copy Cloner I have a postflight script that sends me e-mail when a backup operation is complete. If I don't get that e-mail I know that something's gone awry.

Simple, but useful stuff.

mnewman 06-22-2010 09:31 PM

Here's an understandable Postfix tutorial: Postfix Basic Configuration

I think you could probably get away with changing just one or two entries in main.cf:

myhostname: must be a real, resolvable domain name. I own mgnewman.com, so that's what I use here.

relayhost: my ISP won't relay e-mail so I set this to the ISP's SMTP server.

NovaScotian 06-23-2010 10:09 AM

Thanks for all of that. I do have a .ca domain name and a dynDNS.org pointer to my IP address (dynamic but only changing when my cable ISP rebalances loadings). I intend to send this to smtp.gmail.com:465, with SSL Authentication and a password rather than to my cable ISP, so I'll have to read the docs at the link you've provided.

mnewman 06-23-2010 07:05 PM

The destination of the e-mail doesn't affect how you setup Postfix. You just need to put enough information in the configuration file so that the servers along the way who relay and ultimately receive the e-mail will "know" that it's genuine and not from a spam-bot.

Here's what the headers look like for mail sent from the command line on my Mac to my Dot Mac account:

Quote:

Return-path: <myoriginname@mgnewman.com>
Received: from smtpin121.mac.com ([unknown] [10.150.68.121])
by ms062.mac.com (Sun Java(tm) System Messaging Server 7u3-12.01 64bit (built
Oct 15 2009)) with ESMTP id <0L4H0047NP6WEXE0@ms062.mac.com> for
myname@mac.com; Wed, 23 Jun 2010 15:59:20 -0700 (PDT)
Original-recipient: rfc822;myname@mac.com
Received: from mailout03.3bb.co.th ([110.164.252.195])
by smtpin121.mac.com (Sun Java(tm) System Messaging Server 7u3-16.01 64bit
(built May 20 2010)) with ESMTP id <0L4H00DLLP6UPU82@smtpin121.mac.com> for
myname@mac.com (ORCPT myname@mac.com); Wed,
23 Jun 2010 15:59:20 -0700 (PDT)
X-Proofpoint-Virus-Version: vendor=fsecure
engine=1.12.8161:2.4.5,1.2.40,4.0.166
definitions=2010-06-23_03:2010-02-06,2010-06-23,2010-06-23 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=3 spamscore=3
ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0
reason=mlx engine=5.0.0-1005130000 definitions=main-1006230149
Received: from mgnewman.com
(adsl-pool-124.157.216-105.dynamic.tttmaxnet.com [124.157.216.105] (may be
forged)) by mailout03.3bb.co.th (8.14.3/8.14.3) with ESMTP id o5NMxFHJ021901
for <myname@mac.com>; Thu, 24 Jun 2010 05:59:16 +0700
Received: by mgnewman.com (Postfix, from userid 501) id E7DD03131F05; Thu,
24 Jun 2010 05:59:14 +0700 (ICT)
To: myname@mac.com
Subject: test
Message-id: <20100623225914.E7DD03131F05@mgnewman.com>
Date: Thu, 24 Jun 2010 05:59:14 +0700 (ICT)
From: myoriginname@mgnewman.com (Mike Newman)
Note that the origin is shown as mgnewman.com even though both the A and M records for that domain point to my web hosting service and not to my local machine. The e-mail system doesn't care, as long as the domain is genuine and resolvable.

(The actual e-mail addresses shown above are fake.)

NovaScotian 06-24-2010 09:04 AM

Thanks, MN


All times are GMT -5. The time now is 10:39 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.