IOS - automatically send an email (NOT from a user account)

How can I send email automatically from the application, for myself, NOT from the user account (this is impossible without user interaction), but from my other email identifier (with the username and password specified in the code)?

+4
source share
2 answers

Yes, you can send emails without user intervention. But you have to use SMTP services on your server side.

Pls Refere: http://iosameer.blogspot.in/2013/01/sending-e-mail-in-background-from-ios_25.html

+2
source

:

#import "SKPSMTPMessage.h"

funtion:

-(void)sendEmail
{

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    //    SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
    testMsg = [[SKPSMTPMessage alloc] init];

    testMsg.fromEmail = [defaults objectForKey:@"fromEmail"];
    testMsg.toEmail = [defaults objectForKey:@"toEmail"];
    testMsg.bccEmail = [defaults objectForKey:@"bccEmal"];
    testMsg.relayHost = [defaults objectForKey:@"relayHost"];
    testMsg.requiresAuth = [[defaults objectForKey:@"requiresAuth"] boolValue];

    if (testMsg.requiresAuth) {
        testMsg.login = [defaults objectForKey:@"login"];

        testMsg.pass = [defaults objectForKey:@"pass"];
    }

    testMsg.wantsSecure = [[defaults objectForKey:@"wantsSecure"] boolValue]; //
    testMsg.subject = @"Your Email subject";
    testMsg.delegate = self;

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [testMsg send];
    });

}

, :

[self sendEmail];

, ... !!!

+1

Source: https://habr.com/ru/post/1569516/


All Articles