I have installed the wsgetmail and registered on O365. Now I’m able to get the system to attempt to pull emails. Problem comes now to this error I’m receiving now.
fetching mail using configuration wsgetmail.json
failed to run command "/opt/rt5/bin/rt-mailgate " for file /tmp/vLFcolmVi8.mime : 19200 at /usr/local/share/perl/5.30.0/App/wsgetmail/MDA.pm line 204.
$ wsgetmail --debug --dry-run --config=wsgetmail.json
fetching mail using configuration wsgetmail.json
making GET request to url https://graph.microsoft.com/v1.0/users/xxxxxxxx@real-time.com/mailFolders at /usr/share/perl/5.34/App/wsgetmail/MS365/Client.pm line 224.
getting system access token at /usr/share/perl/5.34/App/wsgetmail/MS365/Client.pm line 290.
failed to fetch folder detail 403 Forbidden at /usr/share/perl/5.34/App/wsgetmail/MS365.pm line 370.
response from server : {"error":{"code":"ErrorAccessDenied","message":"Access is denied. Check credentials and try again."}} at /usr/share/perl/5.34/App/wsgetmail/MS365.pm line 371.
unable to fetch messages, can't find folder Inbox at /usr/share/perl/5.34/App/wsgetmail/MS365.pm line 418.
Hi, @Bob_Tanner
The instructions aren´t very clear about the permissions.
Also the permissions changed some are delegated other are application.
Try to setup the permissoes like this:
Thanks for the response @ricardoc. I adjusted my permissions to match your screenshot but I cannot get the Admin consent required columns to match yours.
And how to I confirm the inbox folder name? I assumed when I log in via the Outlook web interface, if the folder name is Inbox in the web UI it would be name of the folder I use is wsgetmail?
After your permissions tweaks, still getting permission problem.
$ wsgetmail --debug --dry-run --config=wsgetmail.json
fetching mail using configuration wsgetmail.json
making GET request to url https://graph.microsoft.com/v1.0/users/xxxxxxxx@real-time.com/mailFolders at /usr/share/perl/5.34/App/wsgetmail/MS365/Client.pm line 224.
getting system access token at /usr/share/perl/5.34/App/wsgetmail/MS365/Client.pm line 290.
failed to fetch folder detail 403 Forbidden at /usr/share/perl/5.34/App/wsgetmail/MS365.pm line 370.
response from server : {"error":{"code":"ErrorAccessDenied","message":"Access is denied. Check credentials and try again."}} at /usr/share/perl/5.34/App/wsgetmail/MS365.pm line 371.
unable to fetch messages, can't find folder Inbox at /usr/share/perl/5.34/App/wsgetmail/MS365.pm line 418.
In order to see the folder name @Bob_Tanner you are right.
If you access via web and the folder name is Inbox in the outlook web page that is the folder name.
About the permisssions, when you add new permissions, under the Microsoft Graph you dont see this:
These two buttons: Delegated permissions or Application Permissions lets you decide which type of permissions are you attribuing
You should first click on one and then do the search for the required permission
> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.7
PSEdition Core
GitCommitId 7.2.7
OS Darwin 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:13:56 PDT 2022; root:xnu-8020.240.7~1/RELEASE_ARM64_T6000
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Connect to Graph so I can do some troubleshooting/debugging
> Connect-MgGraph -Scopes "Mail.Read","Mail.Read.Shared","Mail.ReadWrite","Mail.ReadWrite.Shared","openid","User.Read.All" -TenantId 91xxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxx51
Welcome To Microsoft Graph!
I’m stuck trying to get email working. I have an Ubuntu 20.04 vm running RT 5.0.3 / postgres. I have configured wsgetmail, and followed the instructions to setup Microsoft Graph API.
I run:
wsgetmail --debug --dry-run --config=wsgetmail.json
and get the following when the email Inbox is empty:
fetching mail using configuration wsgetmail.json
making GET request to url https://graph.microsoft.com/v1.0/users/something@xxxxxxx.com/mailFolders at /usr/local/share/perl/5.30.0/App/wsgetmail/MS365/Client.pm line 224.
getting system access token at /usr/local/share/perl/5.30.0/App/wsgetmail/MS365/Client.pm line 290.
processed 0 messages
I run it again when there is an email in the Inbox and get a timeout error:
I’ve noticed that this timeout when running the command seems to coincide with my rt-server no longer responding. I restarted it and noted the following new errors, but still can’t reach RT any longer.
Nov 10 19:12:03 hrutil02 systemd[1]: Started RT FCGI server.
Nov 10 19:12:08 hrutil02 RT[678654]: [678654] Failed attempt to create a ticket by email, from me@xxxxxxx.com: me@xxxxxxx.com attempted to create a ticket via email in the queue General; you
might need to grant ‘Everyone’ the CreateTicket right.
Nov 10 19:12:08 hrutil02 postfix/postdrop[678679]: warning: mail_queue_enter: create file maildrop/224998.678679: Permission denied
I’ve gone bald pulling my hair out creating this server. Really appreciate any help / insights you might have
UPDATE:
Changed Default queue to allow “Everyone” to create tickets - Restarted rt-server, then reran wsgetmail dry run - Same timeout at line 3007 as before but RT log shows something different.
Nov 10 19:58:58 hrutil02 systemd[1]: Started RT FCGI server.
Nov 10 20:08:34 hrutil02 RT[681504]: [681504] rt-5.0.3-681504-1668110914-1074.2-7-0@blahSupport#2/43 - Scrip 7 On Create Autoreply To Requestors
Nov 10 20:08:34 hrutil02 postfix/postdrop[681886]: warning: mail_queue_enter: create file maildrop/435477.681886: Permission denied
Nov 10 20:08:44 hrutil02 postfix/postdrop[681886]: warning: mail_queue_enter: create file maildrop/435689.681886: Permission denied
Those errors don’t look like they’re coming from RT itself, but from your postfix/postdrop MTA. Looks like it doesn’t have permission to write its files - possibly a permission problem on its mail spool and/or temporary directory. See if you can send an email from outside of RT to check if that works, and if not check the documentation/config for this MTA to work out what user you need to give rights to on this directory.
@GreenJimll - Thank you for the reply - Yes, and just keeps throwing those errors.
It’s odd in that rt is running postdrop which gets the permission error, but rt can write to the maildrop directory. but postfix / MTA issues are another topic.
Regarding WSGetMail - I can see that it will pull mails from my Office 365 / with the MS Graph API permissions. Will it send directly through that same function?
Our old RT server uses fetchmail through a relay windows server to POP3 which is dead on Dec 31. If we still have to relay mails out and wsgetmail doesn’t handle that as well, I’m curious how people have set that up to work. My RT’s are Azure VM’s.
Update: It is a permissions problem with /var/spool/postfix/maildrop directory
Postfix sets it to: drwxr-x–T
I’ve tried several other combinations of permissions and settled on 777 and then it works. All other email works with the default permissions but wsgetmail. 777 is OK for now.
failed to run command “/opt/rt5/bin/rt-mailgate --url=https://myrtserver.corp.company.com/ --queue=General --action=comment” for file /tmp/q5Lo1TFSZS.mime : 19200 at /usr/local/share/perl/5.30.0/App/wsgetmail/MDA.pm line 204. output : error:HTTP request failed: 503 Service Unavailable. Your webserver logs may have more information or there may be a network problem.
Apache2/error.log says:
[Tue Nov 15 21:56:11.793095 2022] [proxy_fcgi:error] [pid 1014:tid 140243902658304] [client 172.22.129.32:40678] AH01067: Failed to read FastCGI header [Tue Nov 15 21:56:11.793125 2022] [proxy_fcgi:error] [pid 1014:tid 140243902658304] (70014)End of file found: [client 172.22.129.32:40678] AH01075: Error dispatching request to :
Output from /var/log/syslog (I don’t have /var/log/messages) Nov 17 18:27:44 hrutil02 RT: [14259] rt-5.0.3-14259-1668709664-1331.23-7-0@HRSupport#23/153 - Scrip 7 On Create Autoreply To Requestors Nov 17 18:27:44 hrutil02 postfix/postdrop[109032]: warning: unable to look up public/pickup: Permission denied Nov 17 18:27:44 hrutil02 RT: [14259] rt-5.0.3-14259-1668709664-1331.23-7-0@HRSupport sent To: admin@company.com Nov 17 18:28:23 hrutil02 postfix/pickup[105988]: 83C77436C: uid=995 from= Nov 17 18:28:23 hrutil02 postfix/cleanup[109056]: 83C77436C: message-id=rt-5.0.3-14259-1668709664-1331.23-7-0@HRSupport Nov 17 18:28:23 hrutil02 postfix/qmgr[5346]: 83C77436C: from=rt@hrsupport.corp.company.com, size=4058, nrcpt=1 (queue active) Nov 17 18:28:27 hrutil02 postfix/smtp[109059]: 83C77436C: to=admin@company.com, relay=mxb-004dc302.gslb.pphosted.com[185.183.30.93]:25, delay=42, delays=39/0.01/2.6/1.1, dsn=2.0.0, status=sent (250 2.0.0 3kwf24n2tt-1 Message accepted for delivery) Nov 17 18:28:27 hrutil02 postfix/qmgr[5346]: 83C77436C: removed
I changed /var/spool/postfix/public to 777 from it’s default permissions which were drwx–s—
After that tried again and the public/pickup error is gone but still getting this:
I’m logged into RT as root, no sign of any ticket appearing. The email I get to admin looks like a ticket notification:
[Company IT-Test Support Queue #24] AutoReply: First Email to HR Support - Test
Greetings,
This message has been automatically generated in response to the creation of a trouble ticket regarding First Email to HR Support - Test, a summary of which appears below.
There is no need to reply to this message right now. Your ticket has been assigned an ID of [Company IT-Test Support Queue #24].
Please include the string [Company IT-Test Support Queue #24] in the subject line of all future correspondence about this issue. To do so, you may reply to this message.
Thank you,
Does this work?
-Charles
Each time I test it, the number in the test email goes up by one. Now it’s #24. Next test will be #25, yet nothing shows up in the queue logged into RT. Frustrating
Based on the example config for wsgetmail.json this is what I put which is the same URL that has RT running on it.
{
"client_id": "S E C R E T",
"tenant_id": "S E C R E T",
"secret": "S E C R E T",
"global_access": 1,
"username": "hrsupport@company.com",
"folder": "Inbox",
"command": "/opt/rt5/bin/rt-mailgate",
"command_args": "--url=https://hrsupport.corp.company.com/ --queue=General --action=comment",
"command_timeout": 30,
"action_on_fetched": "mark_as_read"
}
I’ve tried a number of other options there http://system name, http and https://localhost, http and https://127.0.0.1 I’m missing something basic here - Something that should be running that is not I’m guessing. All versions give the 503 error, except https://127.0.0.1 gives a 500 (hostname verification failed) and http://127.0.0.1 gives a 404 error
This is my /etc/apache2/sites-available/default-ssl.conf
I currently don’t have any other sites available file on the assumption that I don’t need anything running non SSL on port 80 or anywhere else:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/cnxwildc.crt
SSLCertificateKeyFile /etc/ssl/private/cnxwildc.key
SSLCertificateChainFile /etc/ssl/certs/gd_bundle-g2-g1.crt
ServerName hrsupport.corp.company.com
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
# SCRIPT_NAME should match RT's WebPath, without a trailing slash.
# This means when WebPath is /, it's the empty string "".
ProxyFCGISetEnvIf true SCRIPT_NAME ""
# The location path in the first argument should match the WebPath in your
# RT site configuration. The network location after fcgi:// should match
# the ListenStream in rt-server.socket.
ProxyPass / fcgi://[::1]:5000/
</VirtualHost>
</IfModule>
That does look like an outgoing email from RT, but you’ve not got a ticket 24 at all in your system? Even if you explicitly go to https://hrsupport.corp.company.com/Ticket/Display.html?id=24 in case some scrip has marked it as resolved/rejected so it isn’t showing up as an active ticket?
As an update, I pointed the WSGetMail script at my running v4 RT system and it worked.
Something is misconfigured with either my RT or my Apache but I have not been able to figure out what. The site is working and can be logged into, but the rt-mailgate command can’t connect - Just gets a 503 Service unavailable error
[proxy_fcgi:error] [pid 675013:tid 140625709373184] (70014)End of file found: [client 172.22.129.32:58216] AH01075: Error dispatching request to :
Short of blowing the whole thing away and starting over, I’ve been over the configs and tried many changes to no avail. Appreciate any help you can give
Finally have been able to get this working, using the debug dry run command, I was able to pin point the problem which was the name of the queue in the fetchmail file.