I m using SKPSMTPMessage files to send the mails but it is showing the following error while sending the email
Error Domain=SKPSMTPMessageError
Code=535 "Invalid username or password."
UserInfo=0xaa2de20 {NSLocalizedRecoverySuggestion=Go to Email Preferences in the application and re-enter your username and password.,
NSLocalizedDescription=Invalid username or password.}
Where should I change the user name and password? The code is as follows:
SKPSMTPMessage *msg = [[SKPSMTPMessage alloc] init];
msg.fromEmail = #"123456789s#gmail.com";
msg.toEmail = to;
msg.relayHost = #"smtp.gmail.com";
msg.requiresAuth = YES;
msg.login = #"123456789#gmail.com";
msg.pass = #"123456789//";
msg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
msg.subject = [NSString stringWithFormat:#"Check Out %# by Docstoc", self.navigationItem.title];
msg.delegate = self;
NSMutableArray *msg_parts = [NSMutableArray array];
NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys:
#"text/html\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey,
[message stringByAppendingString:#"\n"], kSKPSMTPPartMessageKey,
nil];
[msg_parts addObject:plain_text_part];
msg.parts = msg_parts;
[msg send];
Note: This is perfectly working code. Since last week it is showing the error.
try
NSMutableArray *msg_parts = [[NSMutableArray alloc]initWithArray:array];
instead of NSMutableArray *msg_parts = [NSMutableArray array];
Please check your below details are valid or not,
msg.login = #"123456789#gmail.com";
msg.pass = #"123456789//";
Related
In my app, I am fetching the e-mail id from address box using PersonPicker view.
When i select any e-mail id, i try to open the e-mail dialog. But it will just open & close immediatly.
I can't able to solve this issue.
I got code from Here
My code is as follow:
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
// Get the first and the last name. Actually, copy their values using the person object and the appropriate
// properties into two string variables equivalently.
// Watch out the ABRecordCopyValue method below. Also, notice that we cast to NSString *.
NSString *firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSString *lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
// Compose the full name.
NSString *fullName = #"";
// Before adding the first and the last name in the fullName string make sure that these values are filled in.
if (firstName != nil) {
fullName = [fullName stringByAppendingString:firstName];
}
if (lastName != nil) {
fullName = [fullName stringByAppendingString:#" "];
fullName = [fullName stringByAppendingString:lastName];
}
// Get the multivalue e-mail property.
CFTypeRef multivalue = ABRecordCopyValue(person, property);
// Get the index of the selected e-mail. Remember that the e-mail multi-value property is being returned as an array.
CFIndex index = ABMultiValueGetIndexForIdentifier(multivalue, identifier);
// Copy the e-mail value into a string.
email = (NSString *)ABMultiValueCopyValueAtIndex(multivalue, index);
NSLog(#"%#",email);
// Create a temp array in which we'll add all the desired values.
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
[tempArray addObject:fullName];
// Save the email into the tempArray array.
[tempArray addObject:email];
// Now add the tempArray into the contactsArray.
[contactsArray addObject:tempArray];
NSLog(#"%#",contactsArray);
// Release the tempArray.
[tempArray release];
// Reload the table to display the new data.
[table reloadData];
// Dismiss the contacts view controller.
[contacts dismissModalViewControllerAnimated:YES];
[contacts release];
MFMailComposeViewController* Apicker = [[MFMailComposeViewController alloc] init];
if (Apicker != nil)
{
[Apicker setSubject:#""];
NSString * someString = nil;
someString=#"Google";
[Apicker setMessageBody:someString isHTML:YES];
NSArray *toRecipients = [NSArray arrayWithObjects:email, nil];
[Apicker setToRecipients:toRecipients];
Apicker.mailComposeDelegate = self;
[self presentModalViewController:Apicker animated:YES];
[Apicker release];
}
return NO;
}
I think it may be the issue of dismiss & present the modal view.
your problem with dismiss and present is that the two overlap. -- dismiss it and THEN show it kinda like you did BUT you run into a problem because the stuff is animated. dont animate there or delay the presetting till after the dismissal
in my application i am able to send email using smtp server,for that i have enter my correct email id and password.
but when i enter my gmail or yahoo account details i am not able to send the mail.
as i have set my relayHost = #"smtp.gmail.com"; then also i am not able to send the mail.
please help me out this.
following is my code :
-(void)sendEMAIL{
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = str_uname;
NSLog(#"str_Uname=%#",testMsg.fromEmail);
testMsg.toEmail = str_info;
NSLog(#"autoemail=%#",testMsg.toEmail);
testMsg.relayHost = #"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = str_uname;
NSLog(#"autoelogin=%#",testMsg.login);
testMsg.pass = str_password;
NSLog(#"autopass=%#",testMsg.pass);
testMsg.subject = #"Schedule Sms And Email";
testMsg.wantsSecure = YES;
NSString *sendmsg=[[NSString alloc]initWithFormat:#"%#",str_info2];
NSLog(#"automsg=%#",sendmsg);
testMsg.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:#"text/plain",kSKPSMTPPartContentTypeKey,
sendmsg, kSKPSMTPPartMessageKey,#"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
[testMsg send];
}
-(void)messageSent:(SKPSMTPMessage *)message{
[message release];
}
-(void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error{
[message release];
}
you can also source code from hear https://github.com/kailoa/iphone-smtp Its a awesome code using smtp server.
http://iphonesdksnippets.com/send-email-with-attachments-on-iphone.html
use this link is also good....Just download framework from there and use that code.Its nice too.
you can manage relay host for yahoo, gmail, hotmail etc. in this way-
NSArray *arr1 = [fromEmail componentsSeparatedByString:#"#"];
NSArray *arr2 = [[arr1 objectAtIndex:1] componentsSeparatedByString:#"."];
if ([arr2 containsObject:#"gmail"]) {
smtp_message.relayHost = #"smtp.gmail.com";
}
else if ([arr2 containsObject:#"yahoo"]) {
smtp_message.relayHost = #"smtp.mail.yahoo.com";
}
else if ([arr2 containsObject:#"hotmail"] || [arr2 containsObject:#"live"]) {
smtp_message.relayHost = #"smtp.live.com";
}
else
{
NSString *smtpRelay = [[NSString alloc]init];
smtpRelay = [NSString stringWithFormat:#"smtp.%#.com",[arr2 objectAtIndex:0]];
smtp_message.relayHost = smtpRelay;
}
Hello I created a app on iOS 4.3.3 and than downloaded Xcode 4.2.1 and iOS sdk 5. It's a navigation-based application and it has a mutable array for the tableview but it won't create any strings for the array, so i added an object to array in the viewdidload but it is not working! So i added NSlog to the objects in my array and it says null! What should i do?
Here's the viewdidload:
- (void)viewDidLoad
{
[super viewDidLoad];
self.soldc = [NSMutableArray arrayWithCapacity:0];
self.color = [NSMutableArray arrayWithCapacity:0];
appdelegate = (yard_sale_managerAppDelegate *)[[UIApplication sharedApplication] delegate];
appdelegate.object = self;
NSMutableArray *loadi = [[NSMutableArray alloc]initWithCapacity:0];
self.items = loadi;
self.sold = [NSMutableArray arrayWithCapacity:0];
self.prices = [NSMutableArray arrayWithCapacity:0];
alert = [[UIAlertView alloc] initWithTitle:#"Add product" message:#"Enter your product name and price." delegate:self cancelButtonTitle:#"Add" otherButtonTitles:#"Cancel", nil];
[alert addTextFieldWithValue:#"" label:#"name"];
[alert addTextFieldWithValue:#"" label:#"price"];
add = [alert textFieldAtIndex:0];
add.keyboardType = UIKeyboardTypeAlphabet;
add.keyboardAppearance = UIKeyboardAppearanceAlert;
add.autocapitalizationType = UITextAutocapitalizationTypeWords;
add.autocorrectionType = UITextAutocorrectionTypeNo;
add2 = [alert textFieldAtIndex:1];
add2.keyboardType = UIKeyboardTypeNumberPad;
add2.keyboardAppearance = UIKeyboardAppearanceAlert;
add2.autocapitalizationType = UITextAutocapitalizationTypeWords;
add2.autocorrectionType = UITextAutocorrectionTypeNo;
NSLog(#"%i", [color count]);
alert.tag=1;
self.resa = [[UIAlertView alloc] initWithTitle:#"Sale results" message:#"temple" delegate:self cancelButtonTitle:#"Close" otherButtonTitles: nil];
self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
self.prices = [NSMutableArray arrayWithContentsOfFile:[self pricesp]];
self.sold = [NSMutableArray arrayWithContentsOfFile:[self soldp]];
self.soldc = [NSMutableArray arrayWithContentsOfFile:[self soldcp]];
self.color = [NSMutableArray arrayWithContentsOfFile:[self colorsp]];
if ([self.soldc count]==0) {
}
//self.soldc = [NSMutableArray arrayWithContentsOfFile:[self soldcp]];
self.color = [NSMutableArray arrayWithContentsOfFile:[self colorsp]];
[loadi release];
self.resa.tag = 2;
[self.items addObject:#"chair"];
[self.prices addObject:#"30"];
[self.color addObject:#"0"];
NSLog(#"%#",self.items);
}
If you need more information tell me!
This is the log:
2012-01-08 21:31:13.409 yard sale manager[1152:f803] 0
2012-01-08 21:31:13.411 yard sale manager[1152:f803] (null)
edit: read this its important!!!!!
a lot of people didn't notice that piece of code:
[self.items addObject:#"chair"];
[self.prices addObject:#"30"];
[self.color addObject:#"0"];
NSLog(#"%#",self.items);
This line
self.color = [NSMutableArray arrayWithCapacity:0];
instantiates and assigns an empty array, you then do not add anything to it therefore the 0 count.
Then this line
self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
is probably the cause. Does [self itemsp] return a valid file path that points to a file that can be parsed into an NSArray.
There are also a lot of other issues with this code.
Update
This line
self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
must be returning nil.
Confirm by adding this line straight after it
NSLog(#"%#", self.items);
How can I make this assumption
The reason I am making this assumption is because you are getting (null). When you call addObject: on nil you will get nil returned and it is a no-op. As you can see from this snippet
NSMutableArray *myArray = nil;
[myArray addObject:#"Test"];
NSLog(#"%#", myArray);
// => 2012-01-08 20:54:04.708 Untitled[4199:707] (null)
Just because myArray holds a pointer to an NSMutableArray it does not mean that you actually have one.
Therefore the last time you assign to self.items is in:
self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
which means [NSMutableArray arrayWithContentsOfFile:[self itemsp]] is returning nil
Given that NSLog(#"%#",self.items); prints (null) it follows that the self.items NSMutableArray is never created. The only way that could happen is if
self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
returns nil, that is does not read anything, probably because there is nothing at the path.
NSLog self.items right after the statement:
self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
If you are trying to write to the app bundle that won't work, you need to write a directory such as the sandboxed Documents directory.
I used SKPSMTPMessage in my iPhone application. Problem is with multiple recipients. I just need to send email to two recipient.
I'm using the following code:
-(void)sendEmail {
// create soft wait overlay so the user knows whats going on in the background.
[self createWaitOverlay];
//the guts of the message.
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = #"support#dsfaes.co.uk";
// testMsg.toEmail = phone;
testMsg.toEmail=#"manjinderr#gmail.com;
testMsg.relayHost = #"smtp.nman.co.uk";
testMsg.requiresAuth = YES;
testMsg.login = #"support#man.co.uk";
testMsg.pass = #"nfsdxsdfswdrt";
testMsg.subject = #"The Confirmation";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
// Only do this for self-signed certs!
// testMsg.validateSSLChain = NO;
testMsg.delegate = self;
}
Anyone knows how can i send email to 2 recipient
There is the heck solution for this
First Create the recipientsArray which contains your recipients
NSArray* recipientsArray = [NSArray arrayWithObjects:#"abc#abc.com",#"xyz#xyz.com",nil];
Call you sendEmail method
for(NSString* toEmailAddress in recipientsArray){
[self sendEmail:toEmailAddress];
}
Then define your sendEmail method:
-(void)sendEmail:(NSString*)_toEmailAddress {
// create soft wait overlay so the user knows whats going on in the background.
[self createWaitOverlay];
//the guts of the message.
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = #"support#dsfaes.co.uk";
testMsg.toEmail = _toEmailAddress;
testMsg.relayHost = #"smtp.nman.co.uk";
testMsg.requiresAuth = YES;
testMsg.login = #"support#man.co.uk";
testMsg.pass = #"nfsdxsdfswdrt";
testMsg.subject = #"The Confirmation";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
// Only do this for self-signed certs!
// testMsg.validateSSLChain = NO;
testMsg.delegate = self;
}
The following code should add different objects to an NSMutableArray however it adds the same object each time:-
for(int i =0; i < [results count];i++)
{
Reservation *r = [[Reservation alloc] init];
NSDictionary *dict = [results objectAtIndex: i];
r.resId = [dict objectForKey:#"reservationrequest_id"];
r.driver = [dict objectForKey:#"driver_name"];
r.vehicle = [dict objectForKey:#"billing_registration"];
r.startDate = [dict objectForKey:#"hire_from_date"];
r.endDate = [dict objectForKey:#"hire_to_date"];
r.status = [dict objectForKey:#"status_type"];
[self.bookingsObjectArray addObject:r];
[r release];
r = nil;
}
I have exactly the same code that works fine in another part of my app it just uses a Groups class instead of Reservation.
When debugging the code I found that when it does [r release]; 'r' is greyed out but still keeps the same pointer. When it goes back to Reservation *r = [[Reservation alloc] init];
'r' has the same pointer as last time.
Any ideas what might be causing the problem? Thanks in advance.
Chris