Pozdrav!
Imam jednu skriptu za backup mysql i na php 5.3 je radila ispravno. Kad sam php promjenio na 5.6 neče više slati backup maila. Skripta je ovakva:
function send_attachment($file, $file_is_db = true) {
global $send_to, $from, $website, $delete_backup, $html_output;
$sent = 'No';
$subject = 'MySQL backup - ' . ($file_is_db ? 'db dump' : 'report') . ' [' . $website . ']';
$boundary = md5(uniqid(time()));
$mailer = 'Sent by Backup2Mail (c) Marko Dugonjic, www.maratz.com, 2005-2009.';
$body = 'Database backup file:' . "\n" . ' - ' . $file . "\n\n";
$body .= '---' . "\n" . $mailer;
$headers = 'From: ' . $from . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: multipart/mixed; boundary="' . $boundary . '";' . "\n";
$headers .= 'This is a multi-part message in MIME format. ';
$headers .= 'If you are reading this, then your e-mail client probably doesn\'t support MIME.' . "\n";
$headers .= $mailer . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
$headers .= 'Content-Transfer-Encoding: 7bit' . "\n";
$headers .= $body . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Disposition: attachment;' . "\n";
$headers .= 'Content-Type: Application/Octet-Stream; name="' . $file . "\"\n";
$headers .= 'Content-Transfer-Encoding: base64' . "\n\n";
$headers .= chunk_split(base64_encode(implode('', file($file)))) . "\n";
$headers .= '--' . $boundary . '--' . "\n";
if (mail($send_to, $subject, $body, $headers)) {
$sent = 'Yes';
................
...............
grešku javi u:
if (mail($send_to, $subject, $body, $headers)) {
$sent = 'Yes';
PHP Warning: mail(): Multiple or malformed newlines found in index.php on line 119
Ajd za moju dušu zakomentiraj liniju
$headers .= 'MIME-Version: 1.0' . "\n";
pa javi dal radi :)
Pozdrav Dario!
Hvala na odgovoru, al ne radi. Opet ista greška
Sad sam tek vidio.... attachment ti se stavlja u header maila, što od verzije 5.5.26 više neće prolaziti zbog security propusta....
Dakle vjerojatno se radi o liniji
$headers .= chunk_split(base64_encode(implode('', file($file)))) . "\n";
Nisam baš nešto previše radio s mail funkcijom, ali ono što sigurno znam je da attachment mora biti u body-ju, a ne u header-u kao što je do sad....
Pa možda da probaš samo to prebaciti u $body... Znači probaj ubacit na ovo mjesto
$body = 'Database backup file:' . "\n" . ' - ' . $file . "\n\n";
$body .= chunk_split(base64_encode(implode('', file($file)))) . "\n"; // Ova linija je ubačena, a istu iz $header varijable svakako izbaciti.....
$body .= '---' . "\n" . $mailer
Pozdrav Dario!
Opet ne radi ... Pa nije bitno. Morat ču pronači novu skriptu. Obratio sam se na avtora ove skripte, al nema odgovora