Mam klase wysyłającą maila
<?
class Emailer
{
private $sender;
private $recipients;
private $subject;
private $body;
function __construct($sender)
{
$this->sender = $sender;
$this->recipients = array(); }
public function addRecipients($recipient)
{
}
public function setSubject($subject)
{
$this->subject = $subject;
}
public function setBody($body)
{
$this->body = $body;
}
public function nag($email)
{
$header = "From: <$email>\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-type: text/html; charset=utf-8\n";
$header .= "Return-Path: <$email>";
}
public function sendEmail()
{
foreach ($this->recipients as $recipient)
{
$result = mail($recipient,$this->subject,$this->body,$this->nag); if($result)
{
echo 'Wiadomość została wysłana'; }
}
}
}
?>
Dodałem funkcje z nagłówkami nag();
Uruchamiam tak:
<?php
$email = new Emailer($email); //adres od
$email->addRecipients("agencik@gmail.com"); // adres do
$email->setSubject($temat);
$email->setBody($wiadomosc);
$email->nag($email);
$email->sendEmail();
?>
wszystko działało dobrze tylko jak dodałem te nagłówki to otrzymuje taki błąd
Kod
Catchable fatal error: Object of class Emailer could not be converted to string in /home/s/public_html/s-s.eu/mail.class.php on line 28
w lini 28 znajduje się
<?php
$header = "From: <$email>\n";
?>