Lotusscript: From address when sending email as web user
Asked Answered
M

6

5

I have a lotus-script agent which runs as Web User since I need to know who the current user is and process information accordingly. The problem is that when sending a email in this agent the From email address shows the web user email address rather than the one I have defined. I am setting the following fields before I send the email (as mime):

    mailDoc.Form = "Memo"
    mailDoc.Subject = strSubject
    mailDoc.InetSendTo = strFrom
    mailDoc.PostedDate = Now
    mailDoc.Principal = strFrom
    mailDoc.FROM = strFrom
    mailDoc.INETFROM = strFrom
    mailDoc.~INetPrincipal = strFrom
    mailDoc.ReplyTo = strFrom
    mailDoc.SendFrom = strFrom
    mailDoc.SentBy = strFrom
    mailDoc.altFrom = strFrom
    mailDoc.tmpDisplaySentBy = strFrom
    mailDoc.DisplaySent = strFrom
    mailDoc.ToShow = strFrom

    mailDoc.SendTo = strSendTo

But still the From address is shown as the web user's address. What am I missing here? Any help would be really appreciated.

Maples answered 20/5, 2012 at 19:10 Comment(0)
A
3

The field Principal is the proper solution, but the real sender's name will probably be visible under water. Actually, there is different solution: to create the mail directly in the mail.box database. That's what the TeamMail template does on OpenNTF. See http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/Team%20Mail%20Tamer

Of course, this is NOT the proper way, but if you want to obfuscate the sender, there's no other solution.

Well, technically that's not entirely true: you could create an Extension Manager DLL that changes the sender... Dirty, you say? Sure.

Andiron answered 21/5, 2012 at 8:52 Comment(3)
If we are changing the reply address as well and the emails are being sent to non-Notes external mail client, how would the real address be still visible - please elaborate. Thanks D.Bugger.Maples
AFAIK, you cannot override From, it is set by the Router task. If I remember correctly, there's always a trace of the original sender's name (From) in the source of the mail. It might not be displayed by the mail client you use. Disclaimer... I could be wrong of course. ;-)Andiron
You are right - although it's not clearly visible, if you look at the email header information, it's clear who the email comes from. So the original sender (developer/admin who signed that agent) is still shown in the header!!Maples
M
5

Actually searching through the forums I found a solution to this age old problem (http://www-10.lotus.com/ldd/nd6forum.nsf/0/13706561dc7d693f852570af0062fcec?OpenDocument):

Principle = "[email protected]"
maildoc.Form = "Memo"
' Principal overrides From
' Must be formatted as below and must include the domain @xyz.com
' Format should equal: "From User" <[email protected]@DOMAIN>
maildoc.Principal = |"Customer Service" <| + Principle + |@xyz.com>|
maildoc.From = Principle
maildoc.AltFrom = Principle
maildoc.SendFrom = Principle
maildoc.INetFrom = Principle
maildoc.tmpDisplaySentBy = Principle
maildoc.tmpDisplayFrom_Preview = Principle
maildoc.DisplaySent = Principle

Hope this helps other people - this has been a issue for me for a very long time!!

Maples answered 20/5, 2012 at 20:39 Comment(2)
If you look at the mail header, does this really show the email as having come from [email protected]? For example, try testing it to a gmail account and look for any trace that this was sent from another user. I believe that was the case in the past (but it's been a few years...)Discursion
You are right Ken - we found adding mail to mail.box was much better than doing this!Maples
D
4

The security in Lotus Notes won't let you override the actual sender information via LotusScript. The only way to control it is to set the Run on behalf of property of the agent to the user from which the email should appear to come. However, you have to set that using the designer and you can't change it at runtime.

It's hard to tell from your question, but if you've tried that and found that the web user setting is overriding the 'on behalf of' setting, you might try splitting the creation of the email into a second agent, and then having that second agent run not as a web user.

Hope this helps!

Discursion answered 20/5, 2012 at 20:1 Comment(3)
Many thanks Ken, that's exactly what I thought, but then I just found a solution in the forums - I will post it as the answer.Maples
This is not correct. Setting Principal field correctly (including Domino mail domain) solves the issue.Highlander
@Alexey Zimarev No, setting 'Principal' will not solve the issue, the 'Sent by' value will appear if the two addresses / IDs are different, as discussed in this thread.Scene
A
3

The field Principal is the proper solution, but the real sender's name will probably be visible under water. Actually, there is different solution: to create the mail directly in the mail.box database. That's what the TeamMail template does on OpenNTF. See http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/Team%20Mail%20Tamer

Of course, this is NOT the proper way, but if you want to obfuscate the sender, there's no other solution.

Well, technically that's not entirely true: you could create an Extension Manager DLL that changes the sender... Dirty, you say? Sure.

Andiron answered 21/5, 2012 at 8:52 Comment(3)
If we are changing the reply address as well and the emails are being sent to non-Notes external mail client, how would the real address be still visible - please elaborate. Thanks D.Bugger.Maples
AFAIK, you cannot override From, it is set by the Router task. If I remember correctly, there's always a trace of the original sender's name (From) in the source of the mail. It might not be displayed by the mail client you use. Disclaimer... I could be wrong of course. ;-)Andiron
You are right - although it's not clearly visible, if you look at the email header information, it's clear who the email comes from. So the original sender (developer/admin who signed that agent) is still shown in the header!!Maples
H
3

The issue with your code is that you do not set Principal field correctly. It should include @NotesDomain where NotesDomain is your Domino mail domain.

I do it like this in QuerySend

    .INetFrom = |"| + strDispName + |" <| + strEmail + ">"
    .Principal =  |"| + strDispName + |" <| + strEmail + "@" + profile.NotesDomain(0) + ">"
    .From = strEmail
    .tmpDisplaySentBy = strEmail
Highlander answered 31/5, 2013 at 15:14 Comment(1)
Thank you @Alexey-Zimarev This works as expected and is four lines of code. To all the other submitter, thank you as well.Coolidge
N
1

As other already said, unless you create the mail in mail.box, the original sender will always be visible. That is part of the Notes/Domino security.

I posted some code on my blog last year, where you can see how to to do that: http://blog.texasswede.com/lotusscript-mail-notification-class/

Nikola answered 30/5, 2012 at 18:46 Comment(0)
H
1

Thank you, you saved my second day of solution searching!! )

In my case (send notification emails to users outside the Domino server from standard mailbox like [email protected]) I need only to add the following string to memo document: "INetFrom", and put the address there.

So, even if look at source of the mail (on gmail account), I see only the person that mentioned in "INetFrom" field!

So, final code look like (XPages SSJS):

try {
    var memo:NotesDocument = database.createDocument();
    memo.appendItemValue("Form", "Memo");
    memo.appendItemValue("Subject", "Subject text");
    memo.appendItemValue("Body", "Body text");
    memo.appendItemValue("SendTo", "userName");
    memo.appendItemValue("INetFrom", "[email protected]");
    memo.send(); 
}catch (e){
    print ("Send Error: " + e);
}
Hm answered 24/5, 2013 at 7:26 Comment(1)
You are most welcome, although like others have recommended, I would add mail directly to mail.box, if you don't want your mail to end up in the spam folder.Maples

© 2022 - 2024 — McMap. All rights reserved.