Jump to content

Recommended Posts

I am trying to figure out why this will not send an email. Please help

 

Classes file:

 

<?php

 

class Text_email{

public $to = "";

public $subject = "";

public $body = "";

public $header = "";

 

 

function __construct ($to, $subject, $body, $header){

 

$this -> to = $to;

$this -> subject = $subject;

$this -> body = $body;

$this -> header = $header;

 

}

 

function sendEmail() {

 

mail($this->to, $this->subject, $this->body, $this->header);

}

}

 

?>

 

 

Index file:

 

<?php

 

include("./textemail.classes.php");

/*

require_once("./htmlemail.classes.php");

require_once("./attachment.class.php");

require_once("./inc/connect_db.php");

*/

 

$text_email = new Text_email($to, $subject, $body, $header);

 

?>

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Email</title>

</head>

 

<body>

<form id="form1" name="form1" method="post" action="./index.php">

<label>

Type of Email:

<select name="type_select">

<option value="text">Text Email</option>

<option value="html">HTML Email</option>

</select>

</label>

<br />

<br />

<table width="700" border="0" cellspacing="0" cellpadding="3">

 

<tr>

<td><label>To</td>

<td><input type="text" name="to" id="textfield" /></label></td>

</tr>

 

<tr>

<td><label>Subject</td>

<td><input type="text" name="subject" id="textfield" /></label></td>

</tr>

 

<tr>

<td><label>Header</td>

<td><input type="text" name="header" id="textfield" /></label></td>

</tr>

 

<tr>

<td><label>Attachment</td>

<td><input type="text" name="attachment" id="textfield" /></label><input name="attach" type="submit" value="Browse" /></td>

</tr>

 

<tr>

<td><label>Body</td>

<td><textarea name="body" cols="45" rows="5"></textarea></label></td>

</tr>

 

<tr>

<td><input name="send" type="submit" value="Send" /></td>

</tr>

</table>

</form>

 

</body>

</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/149308-sending-email-using-classes/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.