Re: Emailing from a daemon process

2016-08-03 Thread Jens Alfke

> On Jul 7, 2016, at 6:56 PM, Bruce Stephens  wrote:
> 
> Could use a simple Perl script… quick easy and nasty…

We already spent many messages dissecting why simply invoking sendmail doesn’t 
work.

> Works!!!

It might work on your machine, because you’ve configured Postfix to route mail 
properly. It’s not going to work on a stock Mac, because by default Postfix 
will try to connect directly to the SMTP server at the recipient’s domain, and 
that server is very unlikely to accept mail from some random computer on the 
Internet (because spammers.)

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-08-03 Thread Bruce Stephens
Could use a simple Perl script… quick easy and nasty…
#!/usr/bin/perl
# 
…
# from an old online sales system that is still operational
...
{
open(MAIL2,"|/usr/sbin/sendmail -t -f nobody") ||
&mydie("Hmmm, a nasty horrible server error has 
occurred, please contact us...");
print MAIL2 "To: $emailAddress1\n";
print MAIL2 "Subject: The ORDER from $theName\n";
myResult(MAIL2);
close (MAIL2);
};


Works!!!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-08 Thread Jens Alfke

> On Jul 8, 2016, at 8:44 AM, Alastair Houghton  
> wrote:
> 
> It has a very high probability of being marked as spam, whatever headers you 
> use, because it’ll be delivered direct to the recipient’s mail server

Oh — I hadn’t thought of that. I sent my test email to myself, so of course it 
connected to my domain host’s SMTP. I just assumed that had come from my email 
settings.

Yeah, this is pretty unlikely to work these days, for the reasons Alastair 
gave. Any SMTP server but your own ISP’s / domain host’s is going to assume 
you’re a spam-bot.

The answer to “Why is it so hard to send email programmatically?” is basically 
“Because spammers.” (Also “because SMTP was designed in the 1970s/80s with no 
security considerations whatsoever, and we’ve never been able to graft proper 
useable security onto it, for reasons like backward compatibility and 
bike-shedding lack of consensus. Also, securing decentralized systems is hard.”)

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-08 Thread Alastair Houghton
On 8 Jul 2016, at 16:13, Sal Conigliaro  wrote:
> 
> You can send mail using sendmail without having to configure Postfix or
> Sendmail.
> 
> Out of the box OS X can use sendmail to send messages. You can test it by
> doing:
> 
> echo “Subject: Email from OX“ | /usr/sbin/sendmail recipi...@domain.com
> 
> (You’ll have to actually include more email headers so it has less chance
> of being marked as spam)

It has a very high probability of being marked as spam, whatever headers you 
use, because it’ll be delivered direct to the recipient’s mail server, most 
likely from a consumer ISP-owned IP range.  Further, if you aren’t careful 
about the From: address, it’ll fall foul of SPF, DKIM and other similar rules 
intended to prevent spam.

It’s best either to

(a) send via the customer’s own e-mail account, which is tricky to configure 
and means you will need support for TLS (some mail servers only accept outbound 
e-mail over authenticated TLS connections), or

(b) use a web server under your control to actually send the e-mail, and have 
the software make an HTTP POST to trigger it

Kind regards,

Alastair.

--
http://alastairs-place.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-08 Thread Jens Alfke

> On Jul 8, 2016, at 8:13 AM, Sal Conigliaro  wrote:
> 
> You can send mail using sendmail without having to configure Postfix or
> Sendmail.
> Out of the box OS X can use sendmail to send messages.

I didn’t think this would actually work, but I tried it and it does.
It relayed to the SMTP server of my personal email account, judging by the 
headers in the message as received:

Received: from jens.local (xx-xx-xx-xx.dsl.static.fusionbroadband.com 
[xx.xx.xx.xx])
by connor.dreamhost.com (Postfix) with ESMTP id CBE6D2C98217
for ; Fri,  8 Jul 2016 08:37:59 -0700 (PDT)
Received: by jens.local (Postfix, from userid 501)
id 90842F8AC69; Fri,  8 Jul 2016 08:37:27 -0700 (PDT)

(Dreamhost is my domain host / email provider.) I have two email accounts, so I 
don’t know how it decided which one to use. It’s not the first one in the list 
in either Mail’s prefs or the Internet Accounts system pref.

I’m pretty sure this would not work from a daemon process, since there is no 
associated user account to look up mail configurations from, and the 
credentials to users’ SMTP accounts are unavailable since they’re in the users’ 
keychains.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-08 Thread Sal Conigliaro
You can send mail using sendmail without having to configure Postfix or
Sendmail.

Out of the box OS X can use sendmail to send messages. You can test it by
doing:

echo “Subject: Email from OX“ | /usr/sbin/sendmail recipi...@domain.com

(You’ll have to actually include more email headers so it has less chance
of being marked as spam)

Sal

Depending on your customers and product, sending these to your server and
> saving them there could be a support feature allowing you or the user to
> log in and review them when needed. Even if you don't, almost every web
> server is set up with sendmail such that you could utilize it instead.
> --
> Gary L. Wade (Sent from my iPhone)
> http://www.garywade.com/
> On Jul 7, 2016, at 11:01 AM, Carl Hoefs 
> wrote:
> >> The manufacturers are probably running their own SMTP servers, and the
> devices either talk to those directly, or (more likely) send HTTP requests
> to the manufacturer’s web server, which then formats the email and sends it
> to the SMTP server.
> >
> > Yes, this seems to be correct. I just checked such emails and I see the
> manufacturers usually exploit gmail for this purpose (and I have no gmail
> account).

-- 
Sal Conigliaro,
e design
http://www.erinedesign.com
@sconig
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Aandi Inston
> > Is there a way to fire off a simple email from an ObjC Foundation-only
app running in the background

"Just" sending email seems like such a simple thing. But remember, a Mac
doesn't come out of the box able to send mail. It only gets that ability if
it is set up to do so (during initialisation, or later in a mail app). This
setup will include an SMTP server, and may well include personal login
information to that server. Macs do not (unless I missed it: would be
useful) set up a generic configuration that can be used to send mail.

So, if it is set up you would have to either interface with the email app
(if you know what it is), or read and use the preferences of the app (if
they are usable, and you'd rather hope security info wasn't).

Bear in mind too, that the user may not set up any email app, so there is
nothing to build on at all. I don't have any need to send email on most
Macs, so I don't set it up at all. On others, I use webmail like millions
of others; again, nothing to tap into, and the webmail service might not
even offer SMTP.

Now, if you are in a position to do so you can ask your user to set up
mail: you need an SMTP server, an optional port, and perhaps to support
security options securely (keychain?) Sending non-secure email to SMTP is
the absolutely trivial part (unless you want attachments). Bear in mind
many users will not have an SMTP server they can even give you and may be
stuck.

Lastly, sending SMTP traffic to port 25 is exactly the sort of thing that
malware does, so you are likely to hit blocks now or in the future.

Sorry if this is repeating points already made.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Jonathan Mitchell

> On 7 Jul 2016, at 17:13, Carl Hoefs  wrote:
> 
> I have a daemon app built on Foundation (aka "command line tool") running in 
> the background and I need it to issue a textual email on certain conditions. 
> 
> The solutions for emailing that I've been able to find (NSWorkspace, 
> NSSharingService, LSOpenCFURLRef) all involve launching an email client like 
> Mail.app, which is inappropriate for a backgraound daemon process.
> 
> Is there a way to fire off a simple email from an ObjC Foundation-only app 
> running in the background on OS X 10.10.5 (not Server)? I'm told that ages 
> ago there was a handly class named NSMailDelivery, but it's long gone...


Not sure if this will pass muster. It seems reasonably alive in some forks.

https://github.com/MailCore/MailCore

It is a framework though.

J



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Gary L. Wade
Depending on your customers and product, sending these to your server and 
saving them there could be a support feature allowing you or the user to log in 
and review them when needed. Even if you don't, almost every web server is set 
up with sendmail such that you could utilize it instead.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

On Jul 7, 2016, at 11:01 AM, Carl Hoefs  wrote:

>> The manufacturers are probably running their own SMTP servers, and the 
>> devices either talk to those directly, or (more likely) send HTTP requests 
>> to the manufacturer’s web server, which then formats the email and sends it 
>> to the SMTP server.
> 
> Yes, this seems to be correct. I just checked such emails and I see the 
> manufacturers usually exploit gmail for this purpose (and I have no gmail 
> account).


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Carl Hoefs

> On Jul 7, 2016, at 9:55 AM, Jens Alfke  wrote:
> 
> 
>> On Jul 7, 2016, at 9:44 AM, Carl Hoefs > > wrote:
>> 
>> It seems a bit odd to me that I can connect all sorts of little network 
>> devices (webcams, network monitors, remote power switches, etc) to a LAN and 
>> they can all be set to issue email.
> 
> The manufacturers are probably running their own SMTP servers, and the 
> devices either talk to those directly, or (more likely) send HTTP requests to 
> the manufacturer’s web server, which then formats the email and sends it to 
> the SMTP server.

Yes, this seems to be correct. I just checked such emails and I see the 
manufacturers usually exploit gmail for this purpose (and I have no gmail 
account).

Received: from localhost ([72.87.216.146]) by smtp.gmail.com 


-Carl


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Doug Hill
Another thing to bring up is that users may not want an open Sendmail server 
running on their machine just so a background process can send email without 
the user's intervention. Huh, this is almost like what malware does.

Doug Hill

> On Jul 7, 2016, at 10:46 AM, Jens Alfke  wrote:
> 
> 
>> On Jul 7, 2016, at 10:01 AM, Carl Hoefs  
>> wrote:
>> 
>> I seem to recall that in the distant past I accomplished issuing emails from 
>> a daemon process on Linux by directly interfacing to /usr/sbin/sendmail. Is 
>> this the 'Postfix mail tools' you mentioned?
> 
> Yes, and sendmail on macOS is just a front-end to the Postfix system. The 
> trouble is that Postfix isn’t actually configured, so it looks like all 
> sendmail will do is write the email to a mail queue that’s not being 
> processed by anything. (You can read the main page for sendmail for details.)
> 
> You can set up Postfix without much trouble, but I assume you want your 
> daemon to work on anyone’s machine without them having to spend 5 minutes 
> mucking about with command-line tools first...
> 
> —Jens
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40breaqz.com
> 
> This email sent to cocoa...@breaqz.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Jens Alfke

> On Jul 7, 2016, at 10:01 AM, Carl Hoefs  
> wrote:
> 
> I seem to recall that in the distant past I accomplished issuing emails from 
> a daemon process on Linux by directly interfacing to /usr/sbin/sendmail. Is 
> this the 'Postfix mail tools' you mentioned?

Yes, and sendmail on macOS is just a front-end to the Postfix system. The 
trouble is that Postfix isn’t actually configured, so it looks like all 
sendmail will do is write the email to a mail queue that’s not being processed 
by anything. (You can read the main page for sendmail for details.)

You can set up Postfix without much trouble, but I assume you want your daemon 
to work on anyone’s machine without them having to spend 5 minutes mucking 
about with command-line tools first...

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Carl Hoefs

> On Jul 7, 2016, at 9:55 AM, Jens Alfke  wrote:
> 
> 
>> On Jul 7, 2016, at 9:44 AM, Carl Hoefs > > wrote:
>> 
>> It seems a bit odd to me that I can connect all sorts of little network 
>> devices (webcams, network monitors, remote power switches, etc) to a LAN and 
>> they can all be set to issue email.
> 
> The manufacturers are probably running their own SMTP servers, and the 
> devices either talk to those directly, or (more likely) send HTTP requests to 
> the manufacturer’s web server, which then formats the email and sends it to 
> the SMTP server.

I seem to recall that in the distant past I accomplished issuing emails from a 
daemon process on Linux by directly interfacing to /usr/sbin/sendmail. Is this 
the 'Postfix mail tools' you mentioned?

-Carl


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Jens Alfke

> On Jul 7, 2016, at 9:44 AM, Carl Hoefs  wrote:
> 
> It seems a bit odd to me that I can connect all sorts of little network 
> devices (webcams, network monitors, remote power switches, etc) to a LAN and 
> they can all be set to issue email.

The manufacturers are probably running their own SMTP servers, and the devices 
either talk to those directly, or (more likely) send HTTP requests to the 
manufacturer’s web server, which then formats the email and sends it to the 
SMTP server.

—Jens

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Carl Hoefs

> On Jul 7, 2016, at 9:33 AM, Jens Alfke  wrote:
> 
>> On Jul 7, 2016, at 9:13 AM, Carl Hoefs > > wrote:
>> 
>> I have a daemon app built on Foundation (aka "command line tool") running in 
>> the background and I need it to issue a textual email on certain conditions. 
> 
> Do you mean daemon or agent? A daemon runs outside of any user login session 
> and is usually started at boot time. An agent has no UI but is part of the 
> login session. This is significant, because an agent process can communicate 
> with GUI apps using AppleEvents or XPC.

It's a daemon, started at boot time and runs outside of a user login. Even so, 
it wouldn't be appropriate to communicate with a GUI app, which still requires 
user intervention, if only to press the Send button.

> 
> There isn’t any easy way of doing this that I know of, if you can’t tell 
> Mail.app to do it. There are built-in Postfix mail tools, but they’re not 
> configured for relaying mail to a server. You’d have to talk to the SMTP 
> server yourself, but that involves reading the user prefs to get the server 
> configuration, and likely finding credentials to log in with… (There might be 
> a 3rd party library for doing this, though.)

It seems a bit odd to me that I can connect all sorts of little network devices 
(webcams, network monitors, remote power switches, etc) to a LAN and they can 
all be set to issue email. I didn't really want to go 3rd party, as there is a 
yearly cost to the only package I could find (which is just a dylib, not 
source).

-Carl

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Jens Alfke

> On Jul 7, 2016, at 9:13 AM, Carl Hoefs  wrote:
> 
> I have a daemon app built on Foundation (aka "command line tool") running in 
> the background and I need it to issue a textual email on certain conditions. 

Do you mean daemon or agent? A daemon runs outside of any user login session 
and is usually started at boot time. An agent has no UI but is part of the 
login session. This is significant, because an agent process can communicate 
with GUI apps using AppleEvents or XPC.

There isn’t any easy way of doing this that I know of, if you can’t tell 
Mail.app to do it. There are built-in Postfix mail tools, but they’re not 
configured for relaying mail to a server. You’d have to talk to the SMTP server 
yourself, but that involves reading the user prefs to get the server 
configuration, and likely finding credentials to log in with… (There might be a 
3rd party library for doing this, though.)

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com