A PHP Mail Class

0 min read 77 words

Below is a Mail class I created in PHP, it requires 4 arguments on initiation of the class via the constructor and uses the method ->send() to send the created mail once complete.

class Mail {
var $to;
var $subject;
var $content;
var $headers;

function Mail($to, $subject, $content, $from){

$this->to = $to;
$this->subject = $subject;
$this->content = $content;
$this->headers = "Content-type: text/html; charset=iso-8859-1\r\nFrom: $from";

$this->content = "".$content."";
}

function send(){
return mail($this->to, $this->subject, stripslashes($this->content), $this->headers);
}
}
Tags:
Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags