I have a script which read html files from directory and you can check which file use to php mail body. But the main problem, how to read checked file and assign it to php mail body?
This is my code:
/* Languages preliminaries */
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
$languages = Language::getLanguages();
$iso = Language::getIsoById($defaultLanguage);
$dir = dirname(__FILE__) . "/mails/". $iso . "/" ;
$files = scandir( $dir ) ;
$cnt = count($files) ;
$html = ' <a name="htmllist"></a>
<form method="post" action="'.$_SERVER['REQUEST_URI'].'" >
$html .= '<div>
<table>
<th>HTML FILES</th><th>Edit</th>
<th>Choose</th>'
;
$tokenModules = $_REQUEST['token'];
for( $i = 0; $i < $cnt; $i ++ )
{
if( preg_match('/.html$/', $files[$i]) )
{
$link = '<a href="index.php?tab=AdminModules&token=' . $tokenModules . '&configure=' . urlencode($this->name) . '&file='.$files[$i].'#emaileditor">' ;
$link .= '<img src="' . __PS_BASE_URI__ . 'img/admin/edit.gif" /></a>' ;
$html .= '<tr>
<td>'. $files[$i] . '</td>
<td align="left">'.$link.'</td>
<td><input type="checkbox" name="which[]" value="'.$files[$i].'"> Use '. $files[$i] . ' template</td>
</tr>' ;
}
}
$html .= '</table>' ;
$html .= '</div>' ;
So here I can see all files and near file name I can check. I think that i need check array[] , yes?
But how to get information which is checked? And assign that file to php body?
$to = 'mymail@mail.com';
$subject = "hello";
$body = "";
$headers = 'From: info@mydomain.com' . "\r\n" ;
$headers .= 'Reply-To: info@mydomain.com' . "\r\n";
$headers .= 'BCC: ' . implode(', ', $recipients) . "\r\n";
mail($to, $subject, $body, $headers);
This is my mail to funkcion.