funkce mail() nefunguje, když se nastaví headers

email mi nejde odeslat když se pokouším zadat odesilatele $headers = "From: info@lorem-ipsum.net";
Je vhodné uvést účet a celý skript, takhle tězko hádat.
$msg = "Hello world.";
// use wordwrap() if lines are longer than 70 characters
/* $msg = wordwrap($msg,70); */
$headers = "From: info@apartman-novehrady.cz" ."rn";
// send email
mail("matemake@seznam.cz","Rezervace",$msg,$headers);
header("location: ../index");

když na to tak koukám tak už tuším kde by mohla být chyba. U toho rn tam má bát \r\n a ať přepíšu kolikrát chci tak se ty zpětné lomítka vždy smažou, proč?
Kde se smažou? Ve správci souborů? Tam je možná asi chybka. Nevím, zda přímo tohoto, ale v minulosti tam byly nějaké problémy, kdy při editaci se to ukládalo jinak než mělo.

Tady by však mělo stačit to "\r\n" vyhodit. Pokud je to jen jeden řádek hlavičky, tak konec řádku není potřeba uvádět. Ten se používá, když je těch hodnot hlaviček více.
Mažou se mi ve správci souborů.
Ano já vím, stailo by to tam nepsat, ale plánuji do budoucna těch hlaviček více ale když mi to nefunguje ani tak, není třeba se pouštět dále když mi to nejde :D mým cílem je poslat mailovou přílohu a tam je těch hlaviček tak 5 ne?
Ani jednou mě nenapadlo, že bych někdy chtěl posílat přílohy přes funkci mail() ;-) Jako ne že by to nešlo, ale je to spousta práce. Tož už raději nějaké hotové řešení / hotovou knihovnu.
Mat: je to tak, při uložení se ořezávala \ (lomítka). \n se tedy uložilo jen jako n.
Změnil jsem nastavení, nyní už se neořezávají.

Jinak hlavičky fungují, pokud Vám ne, asi je něco špatně v PHP kódu.
Tudle jsem resil mailovou funkci na prilohy. Klidne to muzes pouzit.
<?php
class classMail
{
public $uid;
public $sep_body;
public $sep_line;
public $head;
public $subj;
public $body;
public $tmp = array();
//private $log = null;

function __construct()
{
$this->newMail();
}

function __destruct()
{
}

public function newMail()
{
$this->tmp = array(
'head'=>array(),
'body'=>array()
);
$this->tmp['head'] = array(
'from' => '',
'to' => '',
'subj' => '',
'notify' => false
);
}

// function clear()
// {
// $this->head = array();
// $this->body = array();
// }

public function addFrom($str) {$this->tmp['head']['from'] = $str;}
public function addTo($str) {$this->tmp['head']['to'] = $str;}
public function addSubj($str) {$this->tmp['head']['subj'] = $str;}
public function addBody($arr)
{
$pos = strrpos($arr['path'],'/');
$arr['file'] = $pos!==false ? substr($arr['path'],$pos+1) : $arr['path'];
$this->tmp['body'][] = $arr;
}
public function addFile($path,$type='',$mime='')
{
$type = $type=='' ? 'file' : $type;
$this->addBody(array('type'=>$type,'path'=>$path,'file'=>'','text'=>'','mime'=>$mime));
}
public function addText($msg,$path='')
{
$this->addBody(array('type'=>'text','path'=>$path,'file'=>'','text'=>$msg));
}
public function addHtml($msg,$path='')
{
$this->addBody(array('type'=>'html','path'=>$path,'file'=>'','text'=>$msg));
}

private function mailAddBody($item) //$type='',$path='',$filename='',$message='',$mime=''
{
$body = array();
if ($item['type']!='')
{
switch ($item['type'])
{
case 'text':
{
$mime = 'text/plain';
$body[] = 'Content-type:'.$mime.'; charset=utf-8'; //'Content-type: text/html; charset=iso-8859-1',
$body[] = 'Content-Transfer-Encoding: quoted-printable';
$body[] = '';
if ($item['text']!='')
{
$body[] = $item['text'];
}
elseif (file_exists($item['path']))
{
$body[] = chunk_split(base64_encode(file_get_contents($path)));
}
else {return;}
break;
}
case 'html':
{
$mime = 'text/html';
$body[] = 'Content-type:'.$mime.'; charset=utf-8';
$body[] = '';
if ($item['text']!='')
{
$body[] = $item['text'];
}
elseif (file_exists($item['path']))
{
$body[] = chunk_split(base64_encode(file_get_contents($path)));
}
else {return;}
break;
}
case 'file':
if (file_exists($item['path']))
{
$mime = $item['mime']=='' ? 'application/octet-stream' : $item['mime'];
$body[] = 'Content-Type:'.$mime.'; name="'.$item['file'].'"';
$body[] = 'Content-Transfer-Encoding: base64';
$body[] = 'Content-Disposition: attachment; filename="'.$item['file'].'"';
$body[] = '';
$body[] = chunk_split(base64_encode(file_get_contents($item['path'])));
}
else {return;}
break;
default: return;
break;
}
}
$this->body[] = $this->sep_body;
$this->body[] = implode($this->sep_line, $body);
$this->body[] = '';
$this->body[] = '';
}

// $head = array('from'=>'','to'=>'','notify'=>true/false)
private function createMail($head=array(),$body=array())
{
$this->uid = '--NextPart uid='.substr(sha1(uniqid(time())),0,20);
$this->sep_body = '--'.$this->uid;
$this->sep_line = PHP_EOL; // "\r\n";
$this->head = array();
$this->head[] = 'From: '.$head['from'];
$this->head[] = 'Reply-To: '.$head['from'];
if ($head['notify']==true)
{
$this->head[] = 'Disposition-Notification-To: '.$head['from'];
$this->head[] = 'Return-Receipt-To: '.$head['from'];
// $this->head[] = 'X-pmrqc: 1';
// $this->head[] = 'X-Confirm-Reading-To: '.$mail['from'];
// $this->head[] = 'Delivery-Status-Notification: '.$mail['from'];
}
$this->head[] = 'MIME-Version: 1.0';
$this->head[] = 'X-Mailer: PHP/' . phpversion();
$this->head[] = 'Content-Type: multipart/mixed; boundary="'.$this->uid.'"';
$this->head[] = 'This is a multi-part message in MIME format.';
$this->subj = "=?UTF-8?B?".base64_encode($head['subj'])."?=";
$this->body = array();
var_dump($body);
foreach($body as $item)
{
$this->mailAddBody($item);
}
$this->body[] = $this->sep_body;
$this->head = implode($this->sep_line, $this->head);
$this->body = implode($this->sep_line, $this->body);
//var_dump($this->head,$this->subj,$this->body);
}

public function send()
{
$head = $this->tmp['head'];
if ( isset($head['from']) && $head['from']!==""
&& isset($head['to' ]) && $head['to' ]!==""
&& isset($head['subj']) && $head['subj']!==""
&& count($this->tmp['body'])>0)
{
$this->createMail($head,$this->tmp['body']);
return mail($head['to'], $head['subj'], $this->body, $this->head);
}
}
}


?>


Pouziti
include './inc/class_mail.php';
$mail = new classMail;
$mail->addFrom($cfg_admin['mail']);
$mail->addTo($usr['mail']);
$mail->addSubj($subj);
$mail->addText($msg);
$bool = $mail->send();
if ($bool)
{$notice[] = $lng['users_list']['resetpsw_mail_true'];}
else {$notice[] = $lng['users_list']['resetpsw_mail_false'];}
$vypis .= nl2br("\n".
'Odesilatel: '.$mail->tmp['head']['from']."\n".
'Prijemce: '.$mail->tmp['head']['to']."\n".
'Predmet: '.$subj."\n-------\n".
$msg."\n\n"
);

na prilohy je tam
addFile($path,$type='',$mime='');
addFile('./userdata/franta/zaloha/zal-1.zip');