Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Email Function is not working Using OOPs.

the mail() function

Moderators: macek, egami, gesf

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

<?php
require "script.php";
?>

<?php
if(isset($_post["submit"])){

$SendMail = new Contact();

$SendMail->first_name = $_post['txtFirstName'];
$SendMail->last_name = $_post['txtLastName'];
$SendMail->from = $_post['txtEmail'];
$SendMail->ContactDetails();
}
?>
<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]*" />
<br/><br/>
<input type="submit" name="submit" value="Send"/>
</form>
===============================================================================

script.php File

<?php

class Contact{
var $first_name;
var $last_name;
var $from;
var $to = 'someone@hotmail.com';
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!";
}
else{
echo "Something wroing with your network!";
}
}
}
?>
zeeshanahmed
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Jul 09, 2014 7:47 pm

Return to PHP coding => Mail

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.