Wednesday, March 25, 2020

Customizing email address for SNDSMTPEMM

giving each snsmtpemm user their own email address

I was asked is it possible for each person who sends email using the Send SMTP Email command, SNDSMTPEMM, to have their own unique email address. This command is used to send SMTP emails from IBM i. I am not going to go into details on how to use and configure your IBM i, I am going to refer you to the following posts:

When writing this post I had to use a Security Officer, *SECOFR, equivalent user profile to do what I needed to do. I do not have an System Operator, *SYSOPR, equivalent profile, therefore, I do not know if that gives you the necessary changes I will describe below.

Let me also say that before you make any of these changes you need to get the OK from the person who is responsible for the IBM i partition you will be making these changes on.

To be able to have a SMTP email address the user needs to have a System Directory Entry. If they do not you need to add them. This posts describes how to add a user to the System Directory Entry. In this example my Programmer user profile has already been added to the System Directory.

I need to work with my entry, I do so using the Work With Directory Entries command, WRKDIRE. I need to pass two parameters to the command:

  1. User profile. In this example the user profile is "SIMON".
  2. Address. 99% of the time this is the same name as IBM i partition. In this example the name of the address is "SYSTEM1".
WRKDIRE USRID(SIMON SYSTEM1)

When I press Enter and the Work with Directories Entries screen is displayed with just the entry for this profile and address. I am not going to bother to show this screen as all I need to do is just put a "2" next to the entry and press Enter.

The Change Directory Entry screen is displayed. Here I need to press F19 to "Change name for SMTP".

As I have not done this before I get the following message at the bottom of my screen:

User ID/address does not exist in SMTP table. Press Enter
to add, F12 to ...

As it says I press Enter as I want to add, and the Add Name for SMTP screen is displayed:

                              Add Name for SMTP

Type choices, press Enter.

   User ID . . . . . . . . :   SIMON
   Address . . . . . . . . :   SYSTEM1


   SMTP user ID  . . . . . .                          
   SMTP domain . . . . . . .                                 
                                                             
                                                             
                                              

   SMTP route  . . . . . . .                                 
                                                             
                                                             
                                              


 F3=Exit   F4=Prompt   F12=Cancel

On this screen I just need to fill in the first two fields. The SMTP route field must be left blank.

  1. SMTP user id:  The name I want to come before the @ sign in the email address.
  2. SMTP domain:  The name of the domain I want the email to come from.
                              Add Name for SMTP

Type choices, press Enter.

   User ID . . . . . . . . :   SIMON
   Address . . . . . . . . :   SYSTEM1


   SMTP user ID  . . . . . .   the_man                
   SMTP domain . . . . . . .   system1.com                   
                                                             


And press Enter. I am returned to the previous screen, Change Directory Entry, and the following message is displayed at the bottom of the screen:

SMTP table updates pending.  Press Enter to update.

I press Enter and my changes are saved.

Now I send myself an email:

SNDSMTPEMM RCP((SIMON@RPGPGM.COM)) 
             SUBJECT('This is a test')
             NOTE(TEST)

I receive this:

From: the_man@system1.com
To: simon@rpgpgm.com
Date: DD/DD/DDDD TT:TT PM
Subject: This is a test

TEST

If I want to remove the SMTP settings I put a "2" next to my entry. When I am back in the Change Directory Entry screen I press F22, "Remove name for SMTP". On the confirmation screen I press Enter to remove the entries I added previously. When I am back at the Change Directory Entry screen I have to press Enter again to confirm the change.

 

This article was written for IBM i 7.4, and should work for some earlier releases too.

2 comments:

  1. Hi Simon,

    The requirements to have a the user registered in the System Directory Entry depends on the settings for the SMTP attributes. If you use the old settings CHGSMTPA DIRTYPE(*SDD) you need the entry, but if you use the newer settings DIRTYPE(*SMTPMSF) or DIRTYPE(*SMTP) you do not need a System Directory Enrty.
    I prefer DIRTYPE(*SMTP) as you do not use the old MSF(Mail Server Framework) either.

    Regards Krister Karlsson

    ReplyDelete
  2. Good post, Thank you

    ReplyDelete

To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.