Incoming Mail Settings with Gmail

Incoming Mail Settings with Gmail

by Adam Jenkins -
Number of replies: 12
Picture of Plugin developers

Hello community!

I have been trying to get my moodle to connect to gmail for incoming mail processing. However, it seems that no matter how I configure the settings, moodle cannot connect to the imap server. After enabling incoming mail, I run cron and get this in the output.

Execute scheduled task: Incoming email pickup
... started 14:53:08. Current memory use 15.7MB.
Connecting to imap.gmail.com as sist.ilearn@gmail.com...
Unable to connect to IMAP server. Failed with 'Error connecting to mail server.'
... used 0 dbqueries
... used 30.14386510849 seconds
Scheduled task complete: Incoming email pickup

It appears to be trying to connect but is timing out after 30 seconds. I have completely opened port 993 on the server and firewalls and IMAP is enabled in the Gmail settings.

Has anyone got this working? What's the "trick"?

Thanks,

Adam



Average of ratings: -
In reply to Adam Jenkins

Re: Incoming Mail Settings with Gmail

by Floyd Saner -

Adam,

Have you read through this documentation https://docs.moodle.org/28/en/Email_setup_gmail?

Floyd

In reply to Floyd Saner

Re: Incoming Mail Settings with Gmail

by Adam Jenkins -
Picture of Plugin developers

Hi Floyd,

Yes, I have seen that documentation. However, that page is about configuring Gmail for use as SMPT to send email. I'm trying to get Moodle to check a Gmail account and parse the incoming messages ala new feature in 2.8. https://docs.moodle.org/28/en/New_features#Email_to_private_files

Have you got this feature running?

Thanks,

Adam

In reply to Adam Jenkins

Re: Incoming Mail Settings with Gmail

by Floyd Saner -

Adam,

Sorry, I missed what you were trying to do. I remember trying out some of the new Moodle 2.8 email features right after the version was released. I had some difficulty getting the features to work, but eventually they worked well.  I haven't used them since. I'll try again today and let you know what I did.

Floyd

In reply to Adam Jenkins

Re: Incoming Mail Settings with Gmail

by Floyd Saner -

Adam,

I worked on this quite a while this morning and now have to attend to some other work.

I keep running into the same problem - Moodle cannot connect to the gmail account via imap. I've dug through a lot of discussion boards and went through my gmail account settings.  I believe I have everything configured properly.

Does anyone have this working  - in Moodle 2.8 ability to send a file to the Private File repository by attaching the file to an email?

I'll bet back on this later when I have time.

Thanks,

Floyd

In reply to Floyd Saner

Re: Incoming Mail Settings with Gmail - Update SOLVED!

by Adam Jenkins -
Picture of Plugin developers

Hi Floyd,

I finally managed to get it to work. The problem was outside of Moodle. The firewall chief got the settings backwards and made it possible for outsiders to imap to my server (which my server's internal firewall blocks), but preventing my server from imapping with outside servers (like gmail).

Although they were hesitant to look over the settings again, a little stubborn pushing and all problems were solved! They also found that they were blocking GIT (port 9418) in the same way.

So, I got two problems fixed for the price of one. 

Pretty happy right now,

Adam

PS. Thanks again for taking the time to try to help me. Your efforts are appreciated. Hopefully I can repay the favour in the future.

Average of ratings: Useful (1)
In reply to Adam Jenkins

Re: Incoming Mail Settings with Gmail - Update SOLVED!

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Adam, this is good feedback.  I am still having problems getting my reply-to-forum-emails working, so I have been watching your progress.  If you can share any more detail (I am a novice at these things), I would really like to know more.  For example, was it as simple as "don't block port 9418?"  Or were there other tweaks needed.  Which firewall settings were "backwards."

In reply to Adam Jenkins

Re: Incoming Mail Settings with Gmail - Update SOLVED!

by Floyd Saner -

Adam, thanks for posting feedback. Like Rick, I'm still stuck.

Rick, if I recall correctly, you are using a shared Bluehost account.  Is that correct?  I also use a shared Bluehost account for testing and development. I spent some time digging through forums related to Bluehost, and it seems that Bluehost will not allow shared accounts to imap to an outside server. That could be our problem.  I don't have access to any other Moodle 2.8 instance yet.

Floyd

In reply to Floyd Saner

Re: Incoming Mail Settings with Gmail - Update SOLVED!

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Floyd, thanks for your reply.

Not exactly.  I do have a Bluehost "hosted server" with an experimental copy of Moodle running on it.

However, my production Moodle is on a GoDaddy VPS.

I am a novice with all of these email settings and configuration of my server's email system.  But I am now picking up some pointers about some things that I should be exploring.  I might have to wait until my summer break to experiment with some of this, but getting email replies to forum emails working is near the top of my list.

In examples of setting up forum email, it uses Gmail as an example.  I did not take this literally.  I thought that I could use my own server.  But should I be taking the gmail settings literally?  Must I use a gmail server to process forum email replies?

In reply to Adam Jenkins

Re: Incoming Mail Settings with Gmail - Update SOLVED!

by Adam Jenkins -
Picture of Plugin developers

Hi Rick and Floyd,

The firewall issue arose in my context because of the fact that my server is behind several firewalls. Two of these are specialised for dealing with a) inbound traffic and b) outbound traffic. When I requested that the port for IMAPS (993) be opened, I failed to specify that I needed it opened for outbound traffic. So, when the network administrator did his thing, the port was opened in the wrong direction. Once I had found the problem, I asked the network administrator to also open the GIT port 9418 in BOTH directions so I will be able to do git pulls and pushes in the future. Note however that opening GIT was just a bonus and has nothing to do with config for incoming mail. Sorry for the confusion about this, I was just super happy and felt like sharing.

Rick, when you say you're having problems with "reply-to-forum-emails" do you mean to say your connection to the IMPA server is fine? What output do you get from cron.php when your server tries to connect to the IMAP server? Is it like mine was in my first post? Or is it like the output below (from cron.php)?

Connecting to imap.gmail.com as siarn@gmail.com...
Connection established.
Searching for Unseen, Unflagged email in the folder 'INBOX'
Found 0 messages to parse. Parsing...
... used 0 dbqueries
... used 1.5728340148926 seconds

In this case, the "Connection established" is what you need to see. If you see this, there are some other settings you need to take care of to get "reply-to-forum-emails" working:

  1. You must set Site administration>Plugins>Message outputs>Email to 'Always send email from the No reply address'; otherwise users will see the email of the forum poster instead.
  2. Users receiving emails must have permissions to "reply to posts" in the forum. In My case, when I first tested it, I setup the forum in "Separate Groups" mode, and tried to have users respond to a post I made to "All Participants"... it didn't work because the users didn't have permission to post back (reply) to "All Participants".

Hope this helps!

Average of ratings: Useful (3)
In reply to Adam Jenkins

Re: Incoming Mail Settings with Gmail - Update SOLVED!

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Adam, I really appreciate this information that you are providing.