这是我的代码
class Email {
public $name;
public $email;
public $subject;
public $textarea;
public $to = "stereoshoots@gmail.com";
public $header;
function __construct($name, $email, $subject, $textarea) {
$this->name = $name;
$this->email = $email;
$this->subject = $subject;
$this->textarea = $textarea;
$this->header = "From:$this->email \r\n";
$this->header .= "Имя: $this->name \r\n";
$this->sendEmail();
}
public function sendEmail(){
if(mail ($this->to,$this->subject,$this->textarea,$this->header)) {
echo "Отправлено";
}
else {
echo "Ошибка";
}
}
}
$obj = new Email($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['textarea']);
我希望在每封邮件的开头都有客户名称:John Doe。我怎么能通过标题做到这一点?
谢谢