SendMail Throwing NSRangeException


I’m getting the following error when trying to use sendmail:

*** -[NSCFString substringToIndex:]: Range or index out of bounds

Here’s the code:

sendMail (to:"",subject:"Daily Script Run:"&&today,body:"Daily execution on"&&currOS&&"was successful.")

I’ve been using email in the past with little trouble, and now when I turn it back on, I’m getting this.

Let me know what other information you might need. I took a look around the forum and saw a similar post with no answer :frowning:


I can’t seem to create that problem locally but clearly you are not alone. Does it raise that error 100% of the time?

Can you tell us what settings you are using for your Mail Preferences?

Also, you have a pretty simple set of arguments right now – can you try eliminating the body just to see if it’s that.

It’s 100% of the time with 4.11 and 4.12.

I stripped it down to just an email address and it still tossed the exception.

My Mail Prefs are as follows:
Authentication: Login
userName: myQAUser
password: myPassword

Anyone got any ideas? I’m under a bit of “Management Pressure” to start reporting my activities :wink:

I would try against a different email server to see if that works better – I still can’t create that problem here and so I’m thinking it’s a reaction to your mail server.

I tried against my personal mail server. It works. However work is not allowed to use my personal mail server. :wink:

Could it be Microsoft Exchange 2007? Although, I believe I was sending emails using the server after that change was made.

When i use the sendmail command, got the following error:

SRUN_RecursionLimitExceeded: Handlers were called to a depth exceeding the maximum limit(40)


In Eggplant mail configuration,
i configured smtp with login as type by providing username and password.

Most likely that’s because you named your script “SendMail” so it was calling itself! (Everyone makes this mistake at least once :slight_smile: )

Just rename the script and try again.

thanks a lot!!!

it worked after changing the filename. :slight_smile:


I’m getting the same error NSRange Expception***-{NSCFString substringToIndex:]: with the sendmail script.

Our mail server was changed to an new address and now also uses Microsoft Exchange 2010. Our IT guy is having trouble figuring out the issue.
Do you have any suggestions?

You IT administrator needs to make sure that it is configured to allow SMTP mail access (at least from the eggPlant machine).

If that is properly configured it should allow you to send mail once again.

The IT admin did configure the SMTP correctly. Can you be more specific about your recommendation? I am able to receive mail on the eggplant mac but not send it out.

Do you know if there is a problem between Microsoft exchange 2010 and eggplant?

I know that MS 2010 can be properly configured to allow mail access but other have also reported difficulty getting it to work.

The mail communication in eggPlant relies on basic SMTP access. That means that it can’t be encrypted and by default needs to run on port 25. If it’s on a different port you can configure that using an optional SMTP_PORT value in your sendmail command.

You might try doing the following test from the Mac to make sure that you can indeed connect to the SMTP port and send a mail message:

Thanks for your help. The SMTP port on exchange 2010 is 587 instead of the normal 25. Once IT made this change on my MAC Mail along with ssl, it worked. I also had to specify smtp_port: 587 in the sendmail script.