Email-problem

Email-problem

Ruben Jansen -
回帖数:10

Hi,

I've set up a Moodle-server on Fedora (latest release). From inside the school the pupils log in on the internal network (192.168....), and outside via internet (http://moodle. ... .nl). When I post in a forum within my moodle, moodle will send an email to me. I can read it with webmail, but I can't in Outlook Express (it looks empty). In webmail I see that it was sent from 192.168.... .

Is this a cron-problem? In crontab I put
*/5 * * * * wget -q -O /dev/null http://192.168. ..../moodle/admin/cron.php
and I think this causes the internal link in the email, am I right?

What can I do to solve this problem? The external link doesn't work on the pc's of the pupils (they can only use the intranet for moodle in school).

回复Ruben Jansen

Re: Email-problem

Ruben Jansen -

Please, can someone help me with this problem? The problem is that emails sent from forums contain the private ip of my server, but it must have the external ip.

This is the source of a test-mail:

Return-Path: <jan@huygenscollege.nl>
Received: from relay1.qsp.nl (relay01.qsp.nl [193.254.214.12])
	 by marieke.qsp.nl (Cyrus v2.2.8-QSP v1.1) with LMTPA;
	 Mon, 09 Oct 2006 20:48:22 +0200
X-Sieve: CMU Sieve 2.2
Received: from svfilter1.qsp.nl (svfilter1.qsp.nl [193.254.214.13])
	by relay1.qsp.nl (Postfix) with ESMTP id C65C35D362
	for <jan@huygenscollege.nl>; Mon,  9 Oct 2006 20:53:35 +0200 (CEST)
Received: from relay1.qsp.nl ([193.254.214.12])
 by svfilter1.qsp.nl (svfilter1.qsp.nl [193.254.214.13]) (amavisd-new, port 10024)
 with ESMTP id 04827-04-2 for <jan@huygenscollege.nl>;
 Mon,  9 Oct 2006 20:49:11 +0200 (CEST)
Received: from localhost.localdomain (unknown [212.203.11.150])
	by relay1.qsp.nl (Postfix) with ESMTP id 444BA5D176
	for <jan@huygenscollege.nl>; Mon,  9 Oct 2006 20:53:35 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by localhost.localdomain (8.13.5/8.13.5) with ESMTP id k99Io1n0009062
	for <jan@huygenscollege.nl>; Mon, 9 Oct 2006 20:50:01 +0200
Received: (from apache@localhost)
	by localhost.localdomain (8.13.5/8.13.5/Submit) id k99Io1Pf009061;
	Mon, 9 Oct 2006 20:50:01 +0200
X-Authentication-Warning: localhost.localdomain: apache set sender to jan@huygenscollege.nl using -f
To: jan@huygenscollege.nl
Subject: Personeelskamer: Re: Welkom op het forum
Date: Mon, 9 Oct 2006 20:50:01 +0200
From: Ruben Jansen <jan@huygenscollege.nl>
Reply-to: "Beantwoord deze e-mail niet door op \"beantwoorden\" te klikken." <jan@huygenscollege.nl>
Message-ID: <5817ca9c0bca4d2739e20e5138cdfb4b@192.168.100.14>
X-Priority: 3
X-Mailer: PHPMailer [version Moodle 2006050521]
Precedence: Bulk
List-Id: "Medewerkersforum" <moodleforum3@192.168.100.14>
List-Help: http://192.168.100.14/mod/forum/view.php?f=3
Message-Id: <moodlepost9@192.168.100.14>
In-Reply-To: <moodlepost8@192.168.100.14>
References: <moodlepost8@192.168.100.14>
X-Course-Id: 2
X-Course-Name: Personeelskamer
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="b1_5817ca9c0bca4d2739e20e5138cdfb4b"
X-Virus-Scanned: amavisd-new at qsp.nl
X-Spam-Status: No, hits=2.206 tagged_above=-10 required=5
 tests=[HTML_IMAGE_ONLY_20=0.64, HTML_MESSAGE=0.001,
 HTML_SHORT_LINK_IMG_3=0.518, IP_LINK_PLUS=1.047]
X-Spam-Level: **


--b1_5817ca9c0bca4d2739e20e5138cdfb4b
Content-Type: text/plain; charset = "UTF-8"
Content-Transfer-Encoding: quoted-printable


Personeelskamer -> Forums -> Medewerkersforum -> Welkom op het forum
---------------------------------------------------------------------
Re: Welkom op het forum
door  Ruben Jansen  - maandag, 9 oktober 2006, 19:41
---------------------------------------------------------------------
hallo

---------------------------------------------------------------------
Dit is een kopie van een bericht dat op de Personeelskamer website is
toegevoegd.

Klik op deze link om jouw antwoord via de website toe te voegen:
http://192.168.100.14/mod/forum/post.php?reply=3D9



--b1_5817ca9c0bca4d2739e20e5138cdfb4b
Content-Type: text/html; charset = "UTF-8"
Content-Transfer-Encoding: quoted-printable

<head><link rel=3D"stylesheet" type=3D"text/css" =
href=3D"http://192.168.100.14/theme/standard/styles.php" />
<link rel=3D"stylesheet" type=3D"text/css" =
href=3D"http://192.168.100.14/theme/standard/styles.php" />
<link rel=3D"stylesheet" type=3D"text/css" =
href=3D"http://192.168.100.14/theme/Clouds/styles.php" />
</head>
<body id=3D"email">

<div class=3D"navbar"><a target=3D"_blank" =
href=3D"http://192.168.100.14/course/view.php?id=3D2">Personeelskamer</a> =
&raquo; <a target=3D"_blank" =
href=3D"http://192.168.100.14/mod/forum/index.php?id=3D2">Forums</a> =
&raquo; <a target=3D"_blank" href=3D"http://192.168.100.14/mod/forum/view.=
php?f=3D3">Medewerkersforum</a> &raquo; <a target=3D"_blank" =
href=3D"http://192.168.100.14/mod/forum/discuss.php?d=3D1">Welkom op het =
forum</a></div><table border=3D"0" cellpadding=3D"3" cellspacing=3D"0" =
class=3D"forumpost"><tr class=3D"header"><td width=3D"35" valign=3D"top" =
class=3D"picture left"><a  =
href=3D"http://192.168.100.14/user/view.php?id=3D2&amp;course=3D2"><img =
class=3D"userpicture" align=3D"middle" =
src=3D"" border=3D"0" =
width=3D"35" height=3D"35" alt=3D"" /></a></td><td class=3D"topic"><div =
class=3D"subject">Re: Welkom op het forum</div><div class=3D"author">door  =
<a =
href=3D"http://192.168.100.14/user/view.php?id=3D2&amp;course=3D2">Ruben =
Jansen</a>  - maandag, 9 oktober 2006, 19:41</div></td></tr><tr><td =
class=3D"left side" valign=3D"top">&nbsp;</td><td =
class=3D"content">hallo<div class=3D"commands"><a target=3D"_blank" =
href=3D"http://192.168.100.14/mod/forum/discuss.php?d=3D1&amp;parent=3D8">=
Toon discussiestart</a> | <a target=3D"_blank" href=3D"http://192.168.100.=
14/mod/forum/post.php?reply=3D9">Antwoord</a></div><div class=3D"link"><a =
target=3D"_blank" =
href=3D"http://192.168.100.14/mod/forum/discuss.php?d=3D1#9">Bekijk dit =
bericht in zijn context</a></div></td></tr></table>

</body>



--b1_5817ca9c0bca4d2739e20e5138cdfb4b--

What do I have to change? Again, on the private network the external link doesn't work.
 
回复Ruben Jansen

Re: Email-problem

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
> From inside the school the pupils log in on the internal network (192.168....), and outside via internet (http://moodle. ... .nl)

How did you get that working? The famous CFG->wwwroot allows only one value IMHO.

> I can read it with webmail, but I can't in Outlook Express (it looks empty).

The full mail header you attached in the other mail looks perfectly healthy to me. If Outlook makes a blank space, it has to tell why. ;-(

> In webmail I see that it was sent from 192.168.... .
>
> Is this a cron-problem?

I don't think so. It is normal for a mail server to add its IP address to the e-mail headers. Your server (both Moodle and mail) seems to have the IP 192.168.100.14 so it is not wrong.

If you want to avoid that, you have to have a public mail relay - your own or belonging to your provider. In that case you fill the e-mail information accordingly in your Moodle administration interface.
回复Visvanath Ratnaweera

Re: Email-problem

Ruben Jansen -

> How did you get that working? The famous CFG->wwwroot allows only one value IMHO.

I put something like this in config.php:

$subnet = '192.168';
$client_ip = $_SERVER['REMOTE_ADDR'];
if (strpos($client_ip, $subnet)===0) {
//Internal URL
$CFG-> wwwroot = 'http://192.168.100.14';
}
else {
//External URL
$CFG->wwwroot = 'http://moodle....nl;
}

This works fine, but moodle uses in her communication the 192.168 instead of the external URL, and I would like the external. Thats's why outlook doesn't display the 'graphics' of the mail and all the links to the forums are not accessible from the outside.

The mail is sent so the mailserver works. And if it's not the cron, which file do I havo to change to make it work correctly?

 

回复Ruben Jansen

Re: Email-problem

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
> I put something like this in config.php:

That is a cute trick! I've bookmarked it.

> but moodle uses in her communication the 192.168 instead of the external URL, and I would like the external. Thats's why outlook doesn't display the 'graphics' of the mail

I guess those mails were generated when the students were working in the LAN. Do the in-line images get displayed within the LAN?

In that case I would say, the reaction to your "dual URL policy" is correct.
回复Visvanath Ratnaweera

Re: Email-problem

Steve Power -

I used to use

$CFG->wwwroot = 'http://'.$_SERVER['HTTP_HOST'];

In my config.php file to set $CFG->wwwroot to whatever the server saw when the user connected. I stopped doing this because of the problems with graphics and links which get put into the Moodle database using the absolute url seen when they are entered. I had some internal and some external addresses and the site did not work fully from either side.

A far better solution is to set an internal DNS server to have the internal address for the url used externally (and set on some external dns). I have also set a value in  a local hosts. file pointing to localhost to cover me when working on a laptop with a copy of our moodle away from a network.

Regards
Steve

回复Ruben Jansen

Re: Email-problem

Steve Garcia -
When students log on from school, they are using the explicit IP address, and not the name?

This may not solve your mail header issue, but you should probably see about setting up a "split DNS" so that the name Moodle.x.nl resolves to the 192.168.. address when queried from inside the school (from a 192.168.. address) and the external IP address when queried from outside.  Do you have control of the DNS server?

This will make your life much easier.
回复Steve Garcia

Re: Email-problem

Ruben Jansen -
I don't know for sure, but I'll ask. How can I split the DNS? Can you give me an example?
回复Ruben Jansen

Re: Email-problem

Steve Power -

Ruben

If you have an internal DNS server then you can create an entry in it for http://moodle. ... .nl pointing to 192.168....

This way you can always refer to your site as http://moodle. ... .nl and this address will be translated to 192.168.... or your public IP address as is appropriate.

You will also be able to "play" with the same effect even if you do not have control of your DNS server by editing a file called hosts.

In Windows this is stored in WINDOWS\system32\drivers\etc\ and you can make an entry such as:

192.168....    moodle. ... .nl

Regards
Steve

回复Ruben Jansen

Re: Email-problem

Steve Garcia -
The simplest way to do this is Steve P's suggestion of an internal DNS server that isn't visible from the outside.  This nameserver would have exactly the same entries as your regular nameserver, but all the addresses would be in the 192.168 range.  You would make that the default nameserver for all your on-campus workstations.

Setting the host files on all the workstation is also a very simple and straightforward (but tedious) way to handle this.

If you *do* have access to the DNS server, and if it's running BIND 9, you can set up "views", that resolve addresses differently depending on who's asking (an inside view and an outside view.)  Other nameservers may also support this type of functionality, but I only know BIND.  微笑
回复Steve Garcia

Re: Email-problem

Ruben Jansen -

Thank you all! The solution is the hosts-file on the moodle-server, where I linked the internal address to the external. The wwwroot is now the external address so the mails have that link in it. knipoog