Romil Handoo
Romil Handoo

Reputation: 29

How to send emails to external email IDs from my XPages code

I am trying to send the emails from my XPage, to external email ID (my personal email ID), but getting error while executing the code.

I am running the XPage application on my local domino server. I haven't changed any configuration settings to enable emails/smtp as I am not aware of how to make these changes. This is the local server, and in my XPage application, my requirement is to send emails to personal email id rather than lotus notes mail box. I the server, I haven't configured mail databases for any user.

I tried following ways to send the mail, but nothing worked:

//Approach 1, simply mention from and to as external email addresses
var docMail : NotesDocument = database.createDocument();
docMail.replaceItemValue("Form","memo";
docMail.replaceItemValue("From","[email protected]";//assume this is actual mail id
docMail.replaceItemValue("SendTo","[email protected]";//assume this is actual mail id
docMail.replaceItemValue("Subject","Test mail";//assume this is actual mail id
docMail.send();



//Approach 2, suppose I am logged in as test user1/Dev
//Configured forwarding address for test user1 and test user2 as [email protected] and [email protected] respectively.

var docMail : NotesDocument = database.createDocument();
docMail.replaceItemValue("Form","memo";
docMail.replaceItemValue("SendTo","CN=Test User2/O=Dev";//assume this is actual mail id
docMail.replaceItemValue("Subject","Test mail";//assume this is actual mail id
docMail.send();

Here, docMail.send() is throwing some SMTP error, saying something like destination mail system is unreachable.

After following the instructions given in tech-notes (see the link in below comments), now docMail.send() is throwing error, and the console shows the error message: 'Development/Home is not a known TCP/IP host' (assume Development/Home is my local development server).

Upvotes: 0

Views: 302

Answers (2)

umeli
umeli

Reputation: 1068

According to the documentation https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_ABOUT_FIELDS_THAT_CONTROL_MAILING_OPTIONS.html You should set the Field "sendTo" instead of "To"

Upvotes: 0

Richard Schwartz
Richard Schwartz

Reputation: 14628

If it is saying that the destination mail system is unreachable, that means that your server is unable to open an SMTP connection to gmail.com. Something on your network is blocking it. That might be a local security restriction on the machine where your server is running, or it could be somewhere on your network. In either case, this is a routine countermeasure intended to prevent computers inside your organization from sending out undetected spam messages if they have been taken over by malware.

You're probably going to need to configure your server to use an outbound relay server. Here's an IBM technote that discusses configuring a relay on Domino 8.5. The details may differ for other versions. The help database for the Domino Administration client will contain appropriate details for your version. If you encounter problems setting it up, ServerFault is the appropriate forum for follow-up, not here on StackOverflow.

Upvotes: 3

Related Questions