Search code examples
xpagesxpages-ssjs

Anonymous register an account, will send mail to notify the person in charge


I have facing some difficulty on changing principal : as "Anonymous" in the email during sending an email.

My system is an online system that allow user to register their account, then Admin will just need to click the register button to register their staff in their organization.

For my understanding, Anonymous is a default account in domino system for "outsider" whoever accessing their server / website.

below is my sample coding:

var web = setdoc.getItemValueString("InternetAddress");

var maildoc:NotesDocument = database.createDocument()
maildoc.replaceItemValue("Form", "Memo");
maildoc.replaceItemValue("Subject","Request for Email Account By Applicant);
session.setConvertMime(false);
var stream = session.createStream();
stream.writeText("<html><body>");

stream.writeText("<p>Dear " + "department reviewer" + ",</p>");
stream.writeText('<p>Kindly review this request by '+document1.getItemValueString('Name')+" on "+I18n.toString(@Today(), 'dd/MM/yyyy')+ ",</p>");
stream.writeText("</body></html>");
var body = maildoc.createMIMEEntity("Body");
body.setContentFromText(stream, "text/html;charset=UTF-8", 1725);
stream.close();
maildoc.closeMIMEEntities(true);
session.setConvertMime(true);

maildoc.replaceItemValue("SendTo",document1.getItemValue("Dep_rev"));       
maildoc.send(); 

Attached will be sample photo of my email:

Inbox

Mail

Is there any way to change the Anonymous name to other name?


Solution

  • You are using the current session to send the mail. Therefore the sender is anonymous.

    You have several options:

    1. Use sessionAsSigner to get hold of the database and create your mail document from there. This should change the sender

    2. Set the From and Principal fields to the name of the sender. You must include the Domino domain name at the end of the Principal field ([email protected]@dominodomain)

    3. Set the From and Principal fields and copy the mail directly to mail.box on the server.