I'm creating a contact.php. My plan is to include in the e-maail stuff which the user entered before. (variables) In this case include the sender email, subject and message. I don't want to use PEAR. I want to use my SSMTP which is installed on my Raspberry Pi on Debian.
Code for form + input and textarea:
<form method="POST" action="contact.php?page=log">
<input type="text" name="from_email" placeholder="Your E-Mail"/>
<input type="text" name="subject_email" placeholder="Subject"/>
<textarea rows="5" cols="50" name="message_email" style="width: 100%" placeholder="Message"></textarea>
<input type="submit" name="submite_email" value="Send E-Mail" />
</form>
Code for PHP Email:
<?php
if(isset($_POST['from_email']) and isset($_POST['subject_email']) and isset($_POST['message_email'])){
$to = '[email protected]';
$subject = $_GET['subject_email'];
$message = $_GET['message_email'];
$headers = 'From: '$_GET['from_email'] . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
} ?>
SSMTP and php.ini are set. If I use the default form for this it sends me the email.
<?php
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
You ca use phpmailer class https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php