cPanel経由で受信メールを以下のphpスクリプトにリダイレクトしました。現時点では、データベースへの追加を開始することを確認したら、正しい情報があることをテストできるように、メールの返信を送信するだけです。
私が知る必要があるのは、これを行うために codeigniter をどのように使用するかということです?
また、メールをcPanelのどこにリダイレクトしますか?
このコードをコントローラーに入れてみましたが、メールが戻ってきます。
#!/usr/bin/php -q
<?php
// get contents of email and add to $email
$email = file_get_contents('php://stdin');
// regular expression to get parts of email that I need
preg_match_all("/(To):\s(.*)\n/i", $email, $to);
preg_match_all("/(Subject):\s(.*)\n/i", $email, $subject);
preg_match_all("/(From):\s(.*)\n/i", $email, $from);
// assign parts of email to variables
$sender = $to[2][0];
$sender = trim($sender, ' " ');
$sender_id = explode('@', $sender);
$sender_id = $sender_id[0];
$subject = $subject[2][0];
$from = $from[2][0];
// make a reply email to test the above works
$reply = "Here's your information!\n\nSender: $sender\nSender ID: $sender_id\nFrom: $from\nSubject: $subject";
// send email to test
mail($from, 'From my email pipe!', $reply, 'From:noreply@mydomain.me');
?>