0
votes

I have an e-mail script that I am using to send an e-mail inside SSIS. NOT using the e-mail task since I cannot ping a server from the mail task and it is easier from an e-mail script. Also, the script is a lot better in many ways.

This e-mail script is simple, checks if the server exists, validates the e-mails, and sends the e-mail out.

ISSUE: In my "From" line in the e-mail script, I am using my e-mail address, and when I upload my package to the Integration Services Server and run it, the e-mail task sends the mail successfully. But, when someone else runs my package on the server, the e-mail task succeeds but, no e-mail is sent. No exceptions are thrown nor there are any failures overall. When I switch the "From" e-mail address to their e-mail address, and they run the package: it sends the mail. And when I try to run it with their e-mail address in the from line, it fails to send e-mail.

We use this:

mySmtpClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; 

for crendentials.

So, my question is: Is there a workaround for this? Do you think this is a windows authentication issue? If there is a workaround, can you please direct me towards one or provide one? Thank You.

2
What's the desired behavior, that the From: be updated to whoever is running the package, or that it works for everyone to send it from your email address?Hart CO

2 Answers

0
votes

Hello bank teller, I'm a friend of Bob's and he said I can use his account. Honest. I might take money out but I'll put it back.

This is essentially the conversation that is happening between your mail system and your SSIS package. The mail system isn't trusting that Alice has the authority to send email on Bob's behalf. Why it's silently swallowing the error is dependent on your code. Perhaps there's a status you aren't checking that signals the email was not sent. Update your question with your actual code if you want some eyes to review it.

There are two options for resolution. The first, and probably least agreeable, is to have the From account authorize every possible user. Dumb, horrible and probably violates every practice known to man but it'd entail no code change.

The "right" approach would be to make the From line agree with the Credentials. You'd have some logic to grab the account and assign that to the From line.

0
votes

Figured out the issue. Just like billinkc mentioned, the "right" approach. We had a hardcoded "From" line which was the reason it failed. Our packages get run by a SQL Job that runs a specific package. The package has the e-mail script that was having Windows Authentication issues due to a mismatch in the authentication. The mismatch was between the person running the SQL job and the From line email user. Hence, they never matched. We added a line to our scritp that gets the user running the job and makes that the From line user. And thus, resolved :)