Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:03:07+00:00 2026-06-13T03:03:07+00:00

I see there are many ways to send email in the background (without UI)

  • 0

I see there are many ways to send email in the background (without UI) in iOS devices and without using MFMailComposeViewController class. Most popular examples are fill an online form and press submit button. Here are the most popular methods i see in stackoverflow..

(1) Using your own SMTP client. This approach is working for me but in my private network but not working in my company premises as in company network I am not allowed to use gmail (public emails) and don’t have SMTP details of our company mail server. I am struck here in this approach.

(2) Using CTCoreMessage & Three20 Framework (open source). But here I am not able to find where to download this framework other than git, where my pc VLAN not allowing GIT. Could somebody help me to find out the Three20 Framework downloadable location and share me an example code.

(3) Using HTTP Post: Send your email body to the server and delegate the email sending to the HTTP Server. If this is simple then can somebody help me how to setup your own HTTP Server for sending emails.

Could anybody help in finding any working sample code. I am at end of my project delivery. Posted this long back. No replies till now. Could anybody help me please..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:03:09+00:00Added an answer on June 13, 2026 at 3:03 am

    I might be able to provide some help for the third option, using HTTP Post, since I did implement it once in a project.

    First, I used this nice and simple iOS class to take care of the posting for me.
    Then, the following iOS code snippet should show you how it’s done

    NSString* from = @"sender@email";
    
    NSString* to = @"receiver@email";
    
    NSString* mailCc = @"cc@email";
    
    NSString* message = @"my message"
    
    NSString* subject = @"my subject";
    
    NSURL* url = [NSURL URLWithString:@"http://yourtestsite.com/my_email_script.php"];
    
    //these are $_POST variables sent, so 'from' would be $_POST['from']        
    NSArray *keys = [[NSArray alloc] initWithObjects:@"from", @"to", @"cc", @"subject", @"message", nil];
    NSArray *objects = [[NSArray alloc] initWithObjects:from, to, mailCc, subject, message, nil];  
    NSDictionary *dictionary = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];
    
    
    NSMutableURLRequest* request = [SimplePost urlencodedRequestWithURL:url andDataDictionary:dictionary];
    NSURLResponse* response = [[NSURLResponse alloc] init];
    NSError* error = [[NSError alloc] init];
    
    NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: &response error: &error];
    
    NSString* result = [[NSString alloc] initWithData:returnData encoding:NSStringEncodingConversionAllowLossy];
    
    //I'm checking for 1 because my php script was set to write 1 to the page in case of success and 0 otherwise, so this is simply my implementation
    if([result isEqualToString:@"1"]) {
        NSLog(@"success");
    } else {
        NSLog(@"error");
    
    }
    

    For the PHP file, this should do the trick

    $from = filter_var($_POST['from'], FILTER_SANITIZE_EMAIL);
    
    $to = filter_var($_POST['to'], FILTER_SANITIZE_EMAIL);
    
    $cc = filter_var($_POST['cc'], FILTER_SANITIZE_EMAIL);
    
    $subject = htmlspecialchars(utf8_decode($_POST['subject']));
    
    $message = utf8_decode($_POST['message']);
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'From: ' . $from . "\r\n";
    
    $headers .= 'Cc: ' . $cc . "\r\n";
    
    // Mail it
    if(mail($to, $subject, $message, $headers)) {
        echo("1");
    } else  {
        echo("0");
    
       }
    

    Keep in mind, I’m no PHP expert, so that code might be improved, especially on the security part.

    [edit]
    PHP mailing should already be enabled in most major managed hosting solutions, be it a cheap shared account, a VPS or a dedicated server. But if you plan to send A LOT of emails with this method, then a dedicated server is recommended.

    However, there is a limit of emails you can send and better options than the mail function. You can find more info about this here.

    [later edit]
    It seems the author deleted the SimplePost class. However, the same author made an alternative which should help, called SimpleHTTPRequest. The rest should remain the same

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a Java class library that is in many ways incomplete: there are
I can see there are many ways to use jQuery safely in the javascript
I can see that there are many ways to write the url for rating
There are many ways to start another activity. The most of the overloading methods
How can I sharpen an image using OpenCV ? There are many ways of
Is there a way to see how many items in a dictionary share the
Is there a way to see how many context switches each thread generates? (both
Is there any way to see how many queries are executed in like every
In many programming languages there is the basic equals operator which will see if
There are many ways by which we can attach an event on an HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.