commit 6af24034971100d50ea9cfa9669e1af1803c0902 Author: Dr3amFury Date: Thu Jul 10 00:00:10 2025 +0200 init diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..be6699d --- /dev/null +++ b/README.txt @@ -0,0 +1,65 @@ + +AI Email Generator +================== + +This is a simple AI-powered Email Generator tool that helps users turn rough email drafts into polished emails. +It uses OpenAI's GPT API (gpt-3.5-turbo) to generate emails in various tones and languages. + +--- + +▶ FEATURES: +- Choose between 3 Tones: Formal, Casual, Persuasive +- Supports 25 Languages (English, Swedish, Spanish, French, German, etc.) +- Copy email to clipboard +- Save email as .txt file +- Toggle Dark Mode for better readability + +--- + +▶ INSTALLATION: +1. Make sure your server has PHP 7.4+ and cURL enabled. +2. Create an OpenAI API Key from: + https://platform.openai.com/account/api-keys + +3. Add your API key inside the `config.php` file like this: +```php + 'YOUR_OPENAI_API_KEY_HERE', +]; +?> +``` + +--- + +▶ USAGE: +1. Open `index.php` in your browser. +2. Paste your rough email draft. +3. Select tone and language. +4. Click “Generate Email”. +5. Copy, save, or toggle dark mode as desired. + +--- + +▶ FILES INCLUDED: +- index.php → Main form page +- process.php → Handles API requests and generates the email +- style.css → Styling for the tool (with dark mode) +- config.php → Configuration (API key) +- home.php → landing page +--- + +▶ NOTES: +- You need an active OpenAI API Key with sufficient quota. +- The tool works locally or on any PHP-compatible web server. +- If the buyer wants to integrate this tool into an existing website or system, + it is their responsibility to handle the integration. This tool is provided as a standalone solution. + +--- + +▶ LICENSE: +This project is provided "as is" for personal or commercial use. +No liability is accepted for API costs or usage. + +--- + diff --git a/config.php b/config.php new file mode 100644 index 0000000..5776db7 --- /dev/null +++ b/config.php @@ -0,0 +1,7 @@ + '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', + +]; +?> \ No newline at end of file diff --git a/home.php b/home.php new file mode 100644 index 0000000..e199301 --- /dev/null +++ b/home.php @@ -0,0 +1,26 @@ + + + + + + AI Email Generator + + + +
+

AI Email Generator

+

Effortlessly craft polished, professional emails in seconds.

+ + +
+ + + + diff --git a/index.php b/index.php new file mode 100644 index 0000000..652fd9d --- /dev/null +++ b/index.php @@ -0,0 +1,65 @@ + + + + + AI Email Generator + + + +
+

AI Email Generator

+
+ + + + + + + + + + + +
+
+ + + + diff --git a/process.php b/process.php new file mode 100644 index 0000000..1e02366 --- /dev/null +++ b/process.php @@ -0,0 +1,117 @@ + + + + + AI Email Generator - Result + + + +
+ 'Write this email in a formal tone', + 'casual' => 'Write this email in a casual tone', + 'persuasive' => 'Write this email in a persuasive tone', + ]; + + if (empty($emailInput) || !isset($allowedTones[$tone])) { + die('Invalid Input.'); + } + + // Improved Prompt with strict language response + $prompt = $allowedTones[$tone] . ". Transform this rough text into a polished, professional email in " . $language . ". ONLY reply in " . $language . ":\n\n" . $emailInput; + + // Prepare API request + $apiurl = 'https://api.openai.com/v1/chat/completions'; + + $data = [ + 'model' => 'gpt-3.5-turbo', + 'messages' => [ + ['role' => 'user', 'content' => $prompt], + ], + 'max_tokens' => 500, + 'temperature' => 0.7, + ]; + + $headers = [ + 'Content-Type: application/json', + 'Authorization: Bearer ' . $apikey, + ]; + + // Make API request + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $apiurl); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + $response = curl_exec($ch); + curl_close($ch); + + // Handle response + $result = json_decode($response, true); + + if (isset($result['choices'][0]['message']['content'])) { + $aiEmail = htmlspecialchars($result['choices'][0]['message']['content']); + echo "

Your AI-Generated Email:

"; + echo ""; + } else { + echo "Error: Failed to generate email. Try again later."; + } + ?> +
Copied to clipboard ✔️
+
+ + + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..29f00e6 --- /dev/null +++ b/style.css @@ -0,0 +1,153 @@ +/* Import Google Font */ +@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap'); + +html { + box-sizing: border-box; + width: 100%; + overflow-x: hidden; +} + +*, *::before, *::after { + box-sizing: inherit; +} + +body { + background-color: #f5f7fa; + margin: 0; + font-family: 'Inter', Arial, sans-serif; + color: #333; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + padding: 40px 20px; + transition: background-color 0.3s ease, color 0.3s ease; + width: 100%; +} + +body.dark-mode { + background-color: #121212; + color: #f5f5f5; +} + +.container { + width: 100%; + max-width: 600px; + text-align: center; + padding: 20px; +} + +form, .email-output { + padding: 25px; + background-color: #ffffff; + border-radius: 12px; + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1); + margin-top: 20px; + transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease; +} + +body.dark-mode form, +body.dark-mode .email-output { + background-color: #1e1e1e; + color: #f5f5f5; +} + +label { + font-weight: bold; + display: block; + margin-bottom: 8px; +} + +textarea, select { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; + resize: vertical; + margin-bottom: 15px; +} + +button { + background-color: #3498db; + color: white; + padding: 12px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 16px; + transition: background-color 0.3s ease, transform 0.3s ease; + width: 100%; +} + +button:hover { + background-color: #2980b9; + transform: translateY(-2px); +} + +button + button { + margin-top: 10px; +} + +#copyBtn { + background-color: #2ecc71; +} + +#copyBtn:hover { + background-color: #27ae60; +} + +.back-link { + display: inline-block; + margin-top: 15px; + color: #3498db; + text-decoration: none; +} + +.back-link:hover { + text-decoration: underline; +} + +#toast { + position: fixed; + bottom: 20px; + left: 50%; + transform: translateX(-50%); + background-color: #2ecc71; + color: white; + padding: 12px 20px; + border-radius: 8px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); + transition: opacity 0.3s ease, visibility 0.3s ease; + opacity: 0; + visibility: hidden; + pointer-events: none; + z-index: 9999; +} + +#toast.show { + opacity: 1; + visibility: visible; +} + +@media (max-width: 600px) { + .container { + padding: 10px; + } + + form, .email-output { + padding: 15px; + } + + button { + padding: 10px; + } +} + +.email-output button { + margin-top: 10px; +} + +.email-output pre { + white-space: pre-wrap; + word-wrap: break-word; +}