Jump to content

EMAIL ERROR! Code attached.


Recommended Posts

I get

Invalid email error!
each time i try to send an email to customer service or webmaster. I checked the admin panel and the email i have in there is typed in correctly.

Please view the following "contact-us.php" code and show me what i'm doing wrong! Thanks!

<?php

$useSSL = true;

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');

$errors = array();

$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));

if (Tools::isSubmit('submitMessage'))
{
   if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))
       $errors[] = Tools::displayError('invalid e-mail address');
   elseif (!($message = nl2br2(Tools::getValue('message'))))
       $errors[] = Tools::displayError('message cannot be blank');
   elseif (!Validate::isMessage($message))
       $errors[] = Tools::displayError('invalid message');
   elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))))
       $errors[] = Tools::displayError('please select a contact in the list');
   else
   {
       if (intval($cookie->id_customer))
           $customer = new Customer(intval($cookie->id_customer));
       if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $_POST['from'], '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))
           $smarty->assign('confirmation', 1);
       else
           $errors[] = Tools::displayError('an error occurred while sending message');
   }
}

$email = Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND Validate::isEmail($cookie->email)) ? $cookie->email : ''));
$smarty->assign(array(
   'errors' => $errors,
   'email' => $email
));

$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
include(dirname(__FILE__).'/footer.php');

?>

Link to comment
Share on other sites

I still believe its a BUG in the new contact-us.php file. Maybe someone with better PHP knowledge can compare the two file versions and see why one would work just fine and the other doesn;t and lets get the RIGHT ANSWER to fix it. If its just a paramater setting with ones HOSTING provider and is common, but the older file will work on the common setting, then it would seem

1) It should be maybe an option to decide with CONTACT-US.PHP file to use. Because in setting up the system the pre-chjeck test for the email WORKS...just not once you have your site up and try to use the CONTACT button to send.

Link to comment
Share on other sites

  • 2 weeks later...
Hi I know, that previous version will work - If you look into the code you will see that to email class is not sending any from params so it takes default configuration and then relaying won't be an issue
cheers


For me, no previous version replacing worked, so i've figured out the following and that finally works!

In Mail.php class copy, paste and customize the following lines in Send(...) function:

ini_set('SMTP', 'webmail.blahblah.xx');
ini_set('smtp_port', '[YOUR SMTP PORT NUMBER]');
ini_set('sendmail_from', '[first part of the mail - e.g. if the mail is [email protected] then put there only "name"]');

that's it, this will manually set the smtp parameters.
In the email config just set the option 'sending emais by php function' not smtp (i've tried but didn't worked).

email.php is called each time when an email is being sent from any form of the PS.

Hope this will help you.
Link to comment
Share on other sites

Do you have correct (real settings) in contact settings? I mean email address you are using in contact form must exists on email server (for servers not allowing relaying) I mean in Admin panel: Settings->Contact?

Also for contact form you need real email addresses: Employees->Contacts

Link to comment
Share on other sites

Do you have correct (real settings) in contact settings? I mean email address you are using in contact form must exists on email server (for servers not allowing relaying) I mean in Admin panel: Settings->Contact?

Also for contact form you need real email addresses: Employees->Contacts


The email is the same for everything and exist in Gmail.

I read somewhere that this problem is because i am testing in localhost and i don´t have the router configured to send and receive the emails by port 25 .... It is this true?

Thanks
Link to comment
Share on other sites

  • 4 weeks later...
×
×
  • Create New...