Email Function is not working Using OOPs.

the mail() function

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed Jul 09, 2014 7:47 pm

Email Function is not working Using OOPs.

Postby zeeshanahmed » Wed Jul 09, 2014 7:58 pm

I am using Object Oriented Programming and I have to sent an email but mail is not sending, I don't know why. Please someone help me. Thanks in advance.

My Code:
contact.php File

require "script.php";


$SendMail = new Contact();

$SendMail->first_name = $_post['txtFirstName'];
$SendMail->last_name = $_post['txtLastName'];
$SendMail->from = $_post['txtEmail'];
<form method="post" action="" enctype="multipart/form-data">
<label for="txtFirstName">First Name</label><br/>
<input type="text" name="txtFirstName" required pattern="[A-Za-z]*" /><br/>
<label for="txtLastName">Last Name</label><br/>
<input type="text" name="txtLastName" required pattern="[A-Za-z]*" /><br/>
<label for="txtEmail">Email</label><br/>
<input type="text" name="txtEmail" required pattern="[A-Za-z]*" />
<input type="submit" name="submit" value="Send"/>

script.php File


class Contact{
var $first_name;
var $last_name;
var $from;
var $to = '';
var $email_subject = "Testing Mail";
var $emai_message = "This is testing mail";
public function ContactDetails(){
$headers = 'From:' .$this->from . "\r\n". 'Reply-To:' . $this->to. "\r\n" . 'X-Mailer: PHP/' .phpversion();
$send_contact = @mail($this->to, $email_subject, $emai_message, $headers);
if($send_contact == true){
echo "Mail has been sent!";
echo "Something wroing with your network!";

Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 2 guests