• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can NSMailDelivery be configured programmatically?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can NSMailDelivery be configured programmatically?


  • Subject: Re: Can NSMailDelivery be configured programmatically?
  • From: Dominic Blais <email@hidden>
  • Date: Sat, 3 Jun 2006 11:04:33 -0700

If you simply need them to be able to send mail, you can use the command line sendmail program; they don't need a SMTP server. This has been a standard unix way of sending mail for years.

However, it won't always work correctly.

Unless the user's done some configuration, sendmail will just connect directly to the
destination mail server. This will fail if:


1] The user's ISP or local network blocks outgoing port 25. (A few big ISPs do this.)

2] The user is on a dynamic IP connection, and the destination uses a dynamic IP
blacklist for spam prevention. (Most residental users have dynamic IPs, and a lot
of mail servers use blacklists to block spam zombies.)


3] The user isn't connected to the Internet at the moment. (Entirely possible.)

The fact is, unfortunately, that there's really no good way to script the sending of
mail from a Cocoa application.

Actually, all of those problems are about as likely to happen using an external SMTP server (which will be connected to via port 25, may be on a blacklist and may not be accessible because the internet is not). Many users are daunted by being asked to setup anything related to an acronym and do their SMTP setup by following instructions from their ISP without any real understanding of the concepts. In as much as using sendmail or SMTP is a problem (which is not great, IMO), what you're really saying seems to be there is no good way to send mail from a user's computer.


If you're using mail as a method of "calling home",
you may want to consider setting up a PHP script (or your web language of choice)
to handle form submissions instead. That'll be a lot easier in the long run, and
has the distinct advantage of allowing you an instant response, if necessary.

This is a good idea if it meets the OP's needs. For example, if you do the following PHP page called postmail.php:


<?php
 $to = 'email@hidden';
 $subject = 'AUTOMATIC E-MAIL';
 $message = 'Name = ' . $_GET['name'] . '\nData = ' . $_GET['data']
 mail($destination, $subject, $message);
?>

And, use the following handler in your Cocoa program (or one of the other ways to open a URL):
NSError *error = NULL;
[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.example.com/postmail.php? name=JillHacker&data=foobar"]
encoding:NSUTF8StringEncoding
error:&error];
if (error != NULL)
NSLog([error localizedDescription]);


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Can NSMailDelivery be configured programmatically? (From: Derrick Bass <email@hidden>)
 >Re: Can NSMailDelivery be configured programmatically? (From: Dominic Blais <email@hidden>)
 >Re: Can NSMailDelivery be configured programmatically? (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: Can NSMailDelivery be configured programmatically?
  • Next by Date: Re: Can NSMailDelivery be configured programmatically?
  • Previous by thread: Re: Can NSMailDelivery be configured programmatically?
  • Next by thread: Re: Can NSMailDelivery be configured programmatically?
  • Index(es):
    • Date
    • Thread