{% extends "users/base.html" %} {% block title %}Create Email Pipe{% endblock title %} {% block content %}

Create Email Pipe

{% csrf_token %}

Example php

        
#!/usr/bin/php -q
 <?php
$fd = fopen("php://stdin","r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd,1024);
}
fclose($fd);
   
      $dbx='osman_rc';
      $dbu='osman_rc';
      $dbp='dej4>Y]|lspA&pFi';
   


$server = 'localhost';
$username = $dbu;
$password = $dbp;
$database = $dbx;

try{
	$conn = new PDO("mysql:host=$server;dbname=$database;charset=utf8mb4", $username, $password);
	
	$conn->exec("set names utf8mb4");
	$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
} catch(PDOException $e){
	die( "Connection failed: " . $e->getMessage());




}
$lines = explode("\n", $email);
$from = "";
$subject = "";
$headers = "";
$message = "";
$id="1";
$splittingheaders = true;
for ($i=0; $i < count($lines); $i++) {if($splittingheaders) {$headers = $lines[$i]."\n";
if(preg_match("/^Subject: (.*)/", $lines[$i],$matches)) {$subject = $matches[1];}
if(preg_match("/^From: (.*)/", $lines[$i], $matches)) {$from = $matches[1];}
if(preg_match("/^To:(.*)/", $lines[$i], $matches)) {$to = $matches[1];}}else{$message .= $lines[$i]."\n";}
if(trim($lines[$i])==""){$splittingheaders =false;
}}

preg_match("/[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})/i", $to, $matches);
$to=$matches[0];
 	$queryv = "UPDATE tickets SET msg =:reply_msg WHERE id = :id";
$v='1';
$stmtv = $conn->prepare($queryv);
$stmtv->bindParam(':reply_msg',$from);
$stmtv->bindParam(':id',$id);

$stmtv->execute() ;  
?>


 
    
{% endblock content %} {% include "users/footer.html" %}