K
K
Kot Matpockuh2013-11-16 15:28:26
PHP
Kot Matpockuh, 2013-11-16 15:28:26

Own "feedback" module does not send email to joomla 3.1

I decided to write my own primitive feedback, only sending it to the mail, without confirmations, tickets and other functions.
The code is here: https://dl.dropboxusercontent.com/u/59666091/mod_get_price.zip
my mod_get_price.php:

<?php defined('_JEXEC') or die('Direct Access to this location is not allowed.');

require_once('helper.php');

JHTML::stylesheet('styles.css','modules/mod_get_price/css/');

$input = JFactory::getApplication()->input; // only once on each method
$form_send = $input->get('form_send', 'notsend');

switch($form_send){
    case 'send':

        $your_name = $input->get('your_name', 'No name');
        $your_question = $input->get('your_question', 'No question');

        $send = ModLittleContactHelper::SendMail($your_name, $your_question);
        echo 'Error sending email: ' . $send->message;
        if ( $send !== true ) {
            echo 'Error sending email: ' . $send->message;
        }

        require(JModuleHelper::getLayoutPath('mod_get_price', 'sendok_tmpl'));
        break;

    default:
        require(JModuleHelper::getLayoutPath('mod_get_price', 'default_tmpl'));
}

>

helper.php:
<?php defined('_JEXEC') or die('Direct Access to this location is not allowed.');

class ModLittleContactHelper{
public function SendMail($your_name, $your_question){

    $config = JFactory::getConfig();
    $sender = array($config->get( 'config.mailfrom' ), $config->get( 'config.fromname' ));
 
    $mail->setSender($sender);

    $mail->setSubject('Сообщение с сайта');
    $mail->addRecipient('[email protected]**.su');

    $body = "Вопрос с сайта<br/>";
    $body.= "-------------------------<br/>";
    $body.= "Пользователь: ".$your_name."<br/>";
    $body.= "Вопрос: ".$your_question."<br/>";

    $mail->setBody($body);
    $mail->IsHTML(true);

    $send = $mailer->Send();

    return $send;
  }
}
>

the rest of the files can be found in the archive above ...
why the letters do not go away, I don’t understand

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mobi, 2013-11-16
@kot_matpockuh

And where actually
Well and $mail, but not $mailer in
as above already paid attention.

A
Alexey Blyshko, 2013-11-16
@nekt

Working with mail functions is often not trivial due to differences in the settings of hosters and their fight against spam.
As far as I remember, the most common problem is the sender's address. It must match the account, domain, or something else with the host.
But there are other options as well. Here is a small checklist:
- I don't know the specifics of joomla, but I want to clarify - where do the $mail and $mailer variables in the helper come from?
- Anything written to the error log?
- Is error output enabled? E_ALL?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question