Contact form error [solved]

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
millerx
Forum Members
Forum Members
Posts: 10
Joined: Tue Jan 30, 2007 9:50 am
Location: Nantes - France

Contact form error [solved]

Post by millerx »

Hi everybody !

I've got a problem with the contact_form plugin. I write this simple line in a page :

{contact_form email="contact@nomdedomaine.com"}

When I use it, I've the error message :
"Sorry, the message was not sent. The server may be down!"

I've written a little php script to test the php function "mail" :

if (mail("contact@nomdedomaine.com", "test msg", "ok", "From: Toto \r\n")) {
echo 'Votre message a ete envoyé avec succes.';
return;
}
else {
echo 'Probleme';
}
I put it and ran it in the directory "plugins" and it's OK, this script sends mails.

So, I really don't understand where is the problem with contact_form...

If someone can help me, thanks a lot !

Olivier.
Last edited by millerx on Mon Jun 25, 2007 1:59 pm, edited 1 time in total.
User avatar
mesaverde
Forum Members
Forum Members
Posts: 15
Joined: Sat Apr 07, 2007 3:20 pm
Location: Colorado, USA

Re: Contact form error

Post by mesaverde »

I had a similar problem. The issue was that my web hosting company's email system requires authentication.

You might want to look at the file function.contact_form.php in the the plugins directory. Line 91 reads

Code: Select all

elseif (@mail($to, $subject, $message, $extra))
You can change the variable $extra to include your sending address like you used in your test file.

The "From..." is set in $extra on line 68. I would change it to your authorized email address.

Code: Select all

$extra = "From: Toto <mymail@free.fr>\r\n";
Good luck.
millerx
Forum Members
Forum Members
Posts: 10
Joined: Tue Jan 30, 2007 9:50 am
Location: Nantes - France

Re: Contact form error

Post by millerx »

Hello Mesaverde, and thanks for your answer.

You gave me the idea to change every element of the "mail" command and I've found the answer.

The problem seems to come from the variable $to but I can't explain why.

I 've replaced the line :

elseif (@mail($to, $subject, $message, $extra)) {

by the line
elseif (@mail("mymail@free.fr", $subject, $message, $extra)) {


And it's OK. Very strange, but solved...

Thank you again.  ;D
isaias
New Member
New Member
Posts: 5
Joined: Wed Aug 16, 2006 12:20 am

Re: Contact form error [solved]

Post by isaias »

In my case, the server was complaining about bad headers and it said it contained at invalid code 0D.
I solved the issue by removing the "\n" from the $extra line.


                //Mail headers
                $extra = "From: $name \r";
Post Reply

Return to “CMSMS Core”