1 (edited by Ludo 2004-06-26 20:40)

Topic: mail problem

Hi,

I've already written a post but I haven't obtained simple solution to solve my problem.
So, I sum up.

My webhoster doesn't allow using smtp (fsockopen desactivated on the server).

So I use the local method which works but not as I Want it to.
Mails are send but the from is not the one I defined in the options. The adress which appears is the default one for my webhoster. I don't want forum users to know my real adress so that's why I want an adress like forum@...com appears.

To be sure that php works on the server I've made a test with this:

In an html page I put this:

<form method="POST" action="nadform.php3" name="AVIS">
<input type="hidden" name="champ8[]" value="aucune">
<table width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
<tr>
<td width="817">
<p align="center">
<font face="Verdana" style="font-size: smaller" class=link2>Votre e-mail</font><font face="Verdana"><br>
<small><input type="text" name="champ1" size="20"></small></font></p>

<p align="center"><font face="Verdana" style="font-size: smaller" class=link2>Objet de votre message</font><font face="Verdana"><br>
<small><input type="text" name="champ2" size="20"></small></font></p>

<p align="center"><font face="Verdana" style="font-size: smaller" class=link2>Votre message</font><font face="Verdana"><br>
<small><textarea rows="4" name="champ3" cols="40"></textarea></small></font></p>

</td>
<td width="25">
 </td>
</tr>
</table>
<p align="center"> </p>
<p align="center"><small><font face="Verdana">
<input type="submit" value="Envoyer" class=link3 name="envoyer" onClick="this.value='Patientez...'" style="border-style: solid; border-width: 1; background-color: #10315A"> </font></small> <br>
<br>
</p>
</form>

Then this is the nadform file which is called in the page:

<?
$MailTo = "administrateur@xxxxx.net"; //adresse à laquelle sera envoyé le contenu du formulaire
$MailSubject = "$champ2"; //texte qui va figurer dans le champ "sujet" du email
$MailHeader = "From: $champ1"; //adresse email qui va figurer dans le champ "expéditeur" du email et qui peut être remplacé par la variable "$champx" ("$champ3").

/* Les routines suivantes permettent à chacune des variables de prendre la valeur des champs du formulaire et de les stocker ensuite dans la variable globale MailBody qui constituera le corps du message */

$Envoi = 1; //initialisation de la variable envoi à 1

if ($champ1 == ""){ //nom du champ1
echo("<center class=link2><p> </p>Vous n'avez pas saisi d'email</font><br>"); //message qui s'affiche si le visiteur n'a pas rempli ce champ
$Envoi = 0; //si le champ1 n'a pas été rempli, la variable envoi prend la valeur de 0
}
else {
$MailBody = "Question 1 : $champ1\n"; //si le champ1 contient de l'information, elle est stockée dans la variable MailBody
}
if ($champ2 == ""){
echo("<center class=link2><p> </p>Vous n'avez pas mis d'objet pour le message</font><br>");
$Envoi = 0;
}
else {
$MailBody .= "Question 2 : $champ2\n";
}
if ($champ3 == ""){
echo("<center class=link2><p> </p>Vous n'avez pas écrit de message</font><br>");
$Envoi = 0;
}
else {
$MailBody .= "Question 3 : $champ3\n";
}

//Envoi du message

if ($Envoi == 1) { //vérification que la variable envoi est bien à 1
mail($MailTo, $MailSubject, $MailBody, $MailHeader); //envoi du message
echo("<center class=link2><p> </p>Votre message a bien été envoyé.<br>Nous y répondrons dès que possible s'il y a lieu</font>"); //affichage d'un message de confirmation.
}
?>


So this script works perfectly on my sever and I can define the adress sender I want.

So what's the problem with punbb the best forum? Why a so simple php script works whereas punbb do not?

For information you can consult php.info about my server here: http://ldevergne.free.fr/test.php

I'm really waiting help from everybody here because I'm not a specialist in php langage.

THanks,

Ludo

2

Re: mail problem

No one can help me?

I can't believe that.

Re: mail problem

Try editing email.php and hardcoding the reply-to address in the call to mail(). I can't see why you would want that though. E-mails sent from the forum shouldn't be replied to.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

4

Re: mail problem

Rickard wrote:

Try editing email.php and hardcoding the reply-to address in the call to mail().

I'm able to edit email.php but what do you mean by hardcoding. It seems too hard for me. I don't know what I must modify in this file.

Rickard wrote:

I can't see why you would want that though. E-mails sent from the forum shouldn't be replied to.

You say "shouldn't" and not "can't". And that's the problem. The e-mail adress which appears is my personal adress and I don't want to receive any mail from users to this adress. Moreover, an adress like forum@...com would be better.

I'm sorry again if I ask too much questions but I'm very interested in using PunBB forum because it seems to be a good one and reliable.

Thanks,

Ludo

Re: mail problem

There's no such thing as asking to many questions. What I meant was that why does it matter what the reply-to address is since nobody replies (or should reply) to e-mails sent out by the forum. Why would you ever want to reply to e.g. a notification e-mail?

Regarding the hardcoding of the reply-to adress, open up email.php and look for

$from = $pun_config['o_board_title'].' '.$lang_common['Mailer'].' <'.$pun_config['o_webmaster_email'].'>';

And replace it with e.g.

$from = 'bla@example.com';

or whatever you want.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: mail problem

Rickard wrote:

What I meant was that why does it matter what the reply-to address is since nobody replies (or should reply) to e-mails sent out by the forum. Why would you ever want to reply to e.g. a notification e-mail?

Oh, you would be surprised...   I run a forum (not punBB wink for a _highly_ technical software company - the kind that has people (techies) like Microsoft, Oracle, Nasa, etc as clients.  The forum sends out notification emails with:

        ******************************************************
           PLEASE DO NOT REPLY TO THIS EMAIL.
           THIS IS AN INFORMATION MESSAGE ONLY AS YOU ASKED
           TO BE INFORMED OF ANY REPLYS TO YOUR POST.
        ******************************************************

I regularly get replies from people thinking they are replying to the original author! roll

7 (edited by Ludo 2004-06-28 22:35)

Re: mail problem

Rickard wrote:

Regarding the hardcoding of the reply-to adress, open up email.php and look for

$from = $pun_config['o_board_title'].' '.$lang_common['Mailer'].' <'.$pun_config['o_webmaster_email'].'>';

And replace it with e.g.

$from = 'bla@example.com';

or whatever you want.

I succeded in modfying what you told me to do.

But always the same problem. The e-mail adress I put after $from= doesn't appear. It's always the e-mail adress corresponding to my user account at my webhoster which appears.

Any other idea?

Thanks,

Ludo

Re: mail problem

Just to be sure, you haven't entered an SMTP server in the admin interface, right?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

9

Re: mail problem

Rickard wrote:

Just to be sure, you haven't entered an SMTP server in the admin interface, right?

Absolutely sure. Even if I had done it, remember my webhoster has desactivated the smtp fonction, (fsockopen desactivated on the server) so I would have got an error message "can't connect....)

Ludo

Re: mail problem

Ok, try this. Create a new php script that contains this:

<?php

mail('your@email.com', 'Test', 'Testing...', 'From: blaha@example.com');
exit('Mail sent');

?>

Does that work as expected? You have to replace your@email.com with your actual e-mail address (duh!).

"Programming is like sex: one mistake and you have to support it for the rest of your life."

11

Re: mail problem

Rickard wrote:

Ok, try this. Create a new php script that contains this:

<?php

mail('your@email.com', 'Test', 'Testing...', 'From: blaha@example.com');
exit('Mail sent');

?>

Does that work as expected? You have to replace your@email.com with your actual e-mail address (duh!).

This worked as expected. Indeed, the FROM is the one I defined.

Ludo

Re: mail problem

Ok. I suspect I might know what's wrong. Try replacing your pun_mail function in email.php with this one:

function pun_mail($to, $subject, $message, $from = '')
{
    global $pun_config, $lang_common;

    // Default sender/return address
    if (!$from)
        $from = $pun_config['o_board_title'].' '.$lang_common['Mailer'].' <'.$pun_config['o_webmaster_email'].'>';

    // Make sure all linebreaks are CRLF
    $message = str_replace("\n", "\r\n", pun_linebreaks($message));
    $headers = 'From: '.$from."\r\n".'Date: '.date('r')."\r\n".'MIME-Version: 1.0'."\r\n".'Content-transfer-encoding: 8bit'."\r\n".'Content-type: text/plain; charset='.$lang_common['lang_encoding']."\r\n".'X-Mailer: PunBB Mailer';

    if ($pun_config['o_smtp_host'] != '')
        smtp_mail($to, $subject, $message, $headers);
    else
        mail($to, $subject, $message, $headers);
}
"Programming is like sex: one mistake and you have to support it for the rest of your life."

13 (edited by Ludo 2004-06-30 08:30)

Re: mail problem

I've modified the punmail fonction as you told me.
Unluckily, it doesn't work, I've always got the same FROM.
I also must say that in the e-mail reveived, at the beginning, when I asked for a new pass, I had that:

"MIME-Version: 1.0

Content-transfer-encoding: 8bit

Content-type: text/plain; charset=iso-8859-1

X-Mailer: PunBB Mailer
Message-Id: <20040630082429.87687931D2@perso0.free.fr>
X-Spam-Check: DONE|type 2&3|H 0.000271995
X-Remote-Ip: 212.27.40.248
X-Remote-Reverse: perso0.free.fr
"

Usually there was not that

Any idea?

Ludo

Re: mail problem

I honesly don't have any idea why this is happening. It's hard to diagnose the problem "from here" if you know what I mean. AFAIK you're the only one having this problem.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

15 (edited by Ludo 2004-06-30 12:57)

Re: mail problem

Rickard wrote:

I honesly don't have any idea why this is happening. It's hard to diagnose the problem "from here" if you know what I mean. AFAIK you're the only one having this problem.

I understand you don't want to loose too much time with me beceuse I'm the only one to have that kind of problem. I can understand that whithout any problems. I thank you for the time you gave me.
BUT, who else that PUNBB developper would be able to solve my problem?

It's a very anoying problem. For example when a user write an e-mail to another with forum mailer, the sender appears to be me (the from). It's not a problem affecting only the process of pass forgotten.

Finally, I can't understant why a simple script you gave me for example(see below) works perfectly and PUNBB does not. Is it impossible to use the same script in PUNBB?

<?php

mail('your@email.com', 'Test', 'Testing...', 'From: blaha@example.com');
exit('Mail sent');

?>

If it can help to solve the problem, I'm ready to give you access to my ftp and to make you become temporarly administrator.

Thanksfully,

Ludo