Joomla.it Forum
Joomla! 3 => Joomla! 3 => : psmsrl 09 May 2018, 12:18:45
-
Buongiorno a tutti,
improvvisamente il codice php che sta dietro l'invio email attraverso il componente mailto sembra non funzionare più.
Probabilmente ho fatto qualche modifica che manda in confusione l'interprete, ma non sono riuscito a risalirci.
Oppure potrebbe essere qualcos altro, qualche impostazione che devo modificare da pannello di amministrazione, ma non saprei.
Potreste aiutarmi? Grazie mille in anticipo.
L'errore dopo il submit del form è:
Notice
Questa email non è stata inviata.
Posto qui sotto i codici delle due pagine richiamate.
CONTROLLER.php (sotto components/com_mailto):
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
ini_set("track_errors", 1);
ini_set("log_errors", 1);
ini_set("error_log", "/logz.txt");
ini_set("log_errors_max_len", 0);
defined('_JEXEC') or die;
class MailtoController extends JControllerLegacy
{
public function mailto()
{
global $name;
$session = JFactory::getSession();
$session->set('com_mailto.formtime', time());
$this->input->set('view', 'mailto');
$this->display();
}
public function send()
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$session = JFactory::getSession();
$timeout = $session->get('com_mailto.formtime', 0);
if ($timeout == 0 || time() - $timeout < 5)
{
JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT'));
return $this->mailto();
}
$SiteName = $app->get('sitename');
$link = MailtoHelper::validateHash($this->input->get('link', '', 'post'));
if (!$link || !JUri::isInternal($link))
{
JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT'));
return $this->mailto();
} $headers = array (
'Content-Type:',
'MIME-Version:',
'Content-Transfer-Encoding:',
'bcc:',
'cc:'
);
$fields = array(
'mailto',
'sender',
'from',
'subject',
);
foreach ($fields as $field)
{
foreach ($headers as $header)
{
if (strpos($_POST[$field], $header) !== false)
{
JError::raiseError(403, '');
}
}
}
unset ($headers, $fields);
$email = $this->input->post->getString('mailto', '');
$sender = $this->input->post->getString('sender', '');
$from = $this->input->post->getString('from', '');
$subject_default = JText::sprintf('COM_MAILTO_SENT_BY', $sender);
$subject = $this->input->post->getString('subject', $subject_default);
$error = false;
if (!$email || !JMailHelper::isEmailAddress($email))
{
$error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $email);
JError::raiseWarning(0, $error);
}
if (!$from || !JMailHelper::isEmailAddress($from))
{
$error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $from);
JError::raiseWarning(0, $error);
}
if ($error)
{
return $this->mailto();
}
$msg = JText::_('COM_MAILTO_EMAIL_MSG');
//$link = $link; //sembra apparentemente inutile
$body = sprintf($msg, $SiteName, $sender, $from, $link);
$subject = JMailHelper::cleanSubject($subject);
$body = JMailHelper::cleanBody($body);
$from = JStringPunycode::emailToPunycode($from);
$from = JMailHelper::cleanAddress($from);
$email = JStringPunycode::emailToPunycode($email);
if (JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true)
{
JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT'));
return $this->mailto();
}
$this->input->set('view', 'sent');
$this->display();
}
}
DEFAULT.php (sotto templates/lt_aircoms/html/com_mailto/mailto/):
<?php
defined('_JEXEC') or die;
JHtml::_('behavior.core');
JHtml::_('behavior.keepalive');
$data = $this->get('data');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(pressbutton)
{
var form = document.getElementById('mailtoForm');
if (form.mailto.value == '' || form.from.value == '')
{
alert('" . JText::_('COM_MAILTO_EMAIL_ERR_NOINFO') . "');
return false;
}
form.submit();
}
");
?>
<div id="mailto-window">
<h2>
<?php echo JText::_('COM_MAILTO_EMAIL_TO_A_FRIEND'); ?>
</h2>
<form action="<?php echo JUri::base() ?>index.php" id="mailtoForm" method="post">
<div class="control-group">
<label for="sender_field" class="control-label"><?php echo JText::_('COM_MAILTO_SENDER'); ?></label>
<div class="controls">
<input type="text" id="sender_field" name="sender" value="<?php echo $this->escape($data->sender); ?>">
<>
<>
<div class="control-group">
<label for="mailto_field" class="control-label"><?php echo JText::_('COM_MAILTO_EMAIL_TO'); ?></label>
<div class="controls">
<input type="text" id="mailto_field" name="mailto" value="<?php echo $this->escape($data->mailto); ?>">
<>
<>
<div class="control-group">
<label for="from_field" class="control-label"><?php echo JText::_('COM_MAILTO_YOUR_EMAIL'); ?></label>
<input type="text" id="from_field" name="from" value="<?php echo $this->escape($data->from); ?>">
<>
<div class="control-group">
<label for="subject_field" class="control-label"><?php echo JText::_('COM_MAILTO_SUBJECT'); ?></label>
<input type="text" id="subject_field" name="subject" value="<?php echo $this->escape($data->subject); ?>">
<>
<div class="control-group">
<a href="#" onclick="performClick('theFile');">Seleziona il file da allegare[/url]
<input type="file" id="theFile" />
<>
<div class="control-group">
<button class="btn btn-success" onclick="return Joomla.submitbutton('send');">
<?php echo JText::_('COM_MAILTO_SEND'); ?>
</button>
<button class="btn btn-danger" onclick="window.close();return false;">
<?php echo JText::_('COM_MAILTO_CANCEL'); ?>
</button>
<>
<input type="hidden" name="layout" value="<?php echo $this->getLayout();?>" />
<input type="hidden" name="option" value="com_mailto" />
<input type="hidden" name="task" value="send" />
<input type="hidden" name="tmpl" value="component" />
<input type="hidden" name="link" value="<?php echo $data->link; ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
<>
</body>
</html>
-
quel codice cosa è, tuo o stai modificando
se stai agendo su una tua estensione meglio postare in sviluppo, se invece stai modificando qualcosa di esistente, io prima controllerei i parametri email del tuo hosting.
Modificare le estensioni non è mai la scelta più furba se non lo si fa con la tecnica dell'override ;)
-
Hai ragione...sì, il codice è dell'estensione. I parametri email sono settati correttamente, da dove recupero l'estensione originale?
-
Hai ragione...sì, il codice è dell'estensione. I parametri email sono settati correttamente,
se fossero settati correttamente funzionerebbe!
-
Scusami, magari mi sono spiegato male..i parametri sono corretti perché prima funzionava. Poi ho manipolato quei due file per poter aggiungere un allegato (ho eliminato successivamente la parte aggiunta, ma forse non ho rimesso tutto com'era).
Per quello chiedevo se fosse possibile recuperare da qualche parte i due file originali dell'estensione mailto citati sopra. Help! :\
-
Se è un componente di joomla li recuperi da una distribuzione joomla stessa versione
-
Ho recuperato il componente, ma non riesco comunque ad inviare l'email.
L'errore risulta dal seguente pezzo di codice:
// Verify that this is a local link
if (!$link || !JUri::isInternal($link))
{
// Non-local url...
JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT'));
return $this->mailto();
}
dove, se faccio stampare la variabile $link ottengo un valore vuoto, ma l'url visibile contiene il parametro link valorizzato:
.../index.php/component/mailto/?tmpl=component&template=lt_aircoms&link=f8159dfbe5f215f87d4d567cac1dbccd02818560