Jump to content

Contact Page


Mafia

Recommended Posts

Here's a simple script. You may need to configure your PHP ini files to get this to work.

 

<?
if ($_POST['text']) {
	$senderName = "The Sender"; // The name of the sender
	$senderEmail = "[email protected]"; // The email of the sender
	$receiverEmail = "[email protected]"; // The address where you want to send email
	$emailSubject = "Hello!"; // The subject of the email
	$emailMessage = $_POST['text']; // The message on the email
	$emailHeader = "From: ". $senderName . " <" . $senderEmail . ">\r\n"; // Header fields
	mail($receiverEmail, $emailSubject, $emailMessage, $emailHeader); // The command that sends the email
}
?>
<html>
<head>
</head>
<body>
<form action="thisfile.php" method="post">
<textarea name="text"></textarea>
<br>
<input type="submit" name="submit" value="Submit!">
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794009
Share on other sites

Your INI file stores configuation values for PHP. There are two in particular which relate to your code.

 

ini_set("SMTP", "localhost");
ini_set("smtp_port", 25);

 

You'll only have to modify these if your SMTP server isn't running on localhost or using the default port 25.

 

Your code will probably work, depending on your host. Try it and if you get any errors post them here.

Link to comment
https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794451
Share on other sites

See my sig.

 

<?php

/* < delete this only to activate......

//Please use this code to send a email with html format.
//only set your email address cal the page mail.php

//ini_set("SMTP", "your ip address"); // if needed to set ur ip address ........

//ini_set("smtp_port", "25"); // port your sending smtp from if needed...........

$Full_Name='redarrow'; // This is in the message body of the email.

$Email='[email protected]'; // This is in the message body of the email.

$Messages='hi i am redarrow love php'; // This is in the message body of the email.

    
    $to = 'me@what_ever.com'; // set the email address..........

$subject = 'Testing mail!'; //subject of the email


//$mes is using caternation . << a dot

$mes = "Hello; $Full_Name <br><br> You have recieved an email from $Email <br><br>";
$mes .= "This message below is for your convenience. <br><br> ****************************** <br><br> Full Name: ";
$mes .= $Full_Name;
$mes .= "<br><br>";
$mes .= "Email: ";
$mes .= $Email;
$mes .= "<br><br>";
$mes .= "Message: ";
$mes .= $Messages;
$mes .= "<br><br>****************************** <br><br>This Is An Automatically Generated Message, Do Not Repond!";

$message = $mes; //This is turning a varable to another for the email function.

// These are the headers for the email function very inportant...

$headers = 
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";

// we are saying if the email is ent tell us using the email function.

if(mail($to, $subject, $message, $headers)){

// message was sent.

echo " MAIL WAS SENT TO $to!"; 

}else{

// message was not sent.

echo " SORRY NO MESSAGE SENT TO $to";
}

/* < delete this only to activate.
?>

Link to comment
https://forums.phpfreaks.com/topic/151136-contact-page/#findComment-794453
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.