# 📧 PANDUAN INSTALASI EMAIL SCHEDULER ## Langkah 1: Persiapan Folder Buat struktur folder seperti ini: ``` email-scheduler/ ├── PHPMailer/ (akan dibuat di langkah 2) ├── uploads/ (buat folder ini) ├── email-scheduler.html ├── send-email.php ├── cron-send-emails.php ├── get-scheduled-emails.php ├── view-scheduled-emails.html ├── config.example.php ├── .htaccess ├── .gitignore └── README.md ``` Buat folder uploads: ```bash mkdir uploads chmod 755 uploads ``` ## Langkah 2: Install PHPMailer ### Opsi A: Menggunakan Composer (Recommended) 1. Install Composer jika belum ada: ```bash php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" ``` 2. Install PHPMailer: ```bash php composer.phar require phpmailer/phpmailer ``` 3. Edit file `send-email.php` dan `cron-send-emails.php`, ubah: ```php // Uncomment baris ini: require 'vendor/autoload.php'; // Comment baris-baris ini: // require 'PHPMailer/src/Exception.php'; // require 'PHPMailer/src/PHPMailer.php'; // require 'PHPMailer/src/SMTP.php'; ``` ### Opsi B: Manual (Tanpa Composer) 1. Download PHPMailer: - Kunjungi: https://github.com/PHPMailer/PHPMailer - Klik "Code" > "Download ZIP" - Atau direct link: https://github.com/PHPMailer/PHPMailer/archive/master.zip 2. Extract file ZIP 3. Buat struktur folder: ``` email-scheduler/ └── PHPMailer/ └── src/ ├── Exception.php ├── PHPMailer.php ├── SMTP.php ├── OAuth.php └── POP3.php ``` 4. Copy file dari folder `PHPMailer-master/src/` ke `email-scheduler/PHPMailer/src/` 5. File sudah siap digunakan dengan konfigurasi default ## Langkah 3: Konfigurasi SMTP File sudah dikonfigurasi dengan: - Host: mail.hostinger.com - User: sunaryono@ibei.ac.id - Pass: Sunaryono123!@# - Port: 465 (SSL) **Untuk keamanan lebih baik:** 1. Copy file config.example.php menjadi config.php: ```bash cp config.example.php config.php ``` 2. Edit file `send-email.php` dan `cron-send-emails.php`, tambahkan di awal: ```php require 'config.php'; ``` 3. Hapus atau comment konfigurasi SMTP yang hardcoded ## Langkah 4: Test Instalasi ### Test 1: Cek PHP Version ```bash php -v ``` Pastikan PHP 7.4 atau lebih tinggi ### Test 2: Cek Ekstensi PHP ```bash php -m | grep openssl php -m | grep mbstring ``` Pastikan kedua ekstensi terinstall ### Test 3: Test Kirim Email 1. Buka browser 2. Akses: `http://localhost/email-scheduler/email-scheduler.html` 3. Isi form dan kirim email test ## Langkah 5: Setup Cron Job (untuk Email Terjadwal) ### Di Linux/Ubuntu: 1. Buka crontab: ```bash crontab -e ``` 2. Tambahkan baris ini (jalankan setiap menit): ``` * * * * * /usr/bin/php /path/to/email-scheduler/cron-send-emails.php >> /path/to/email-scheduler/logs/cron.log 2>&1 ``` 3. Ganti `/path/to/email-scheduler/` dengan path lengkap folder Anda 4. Cari path PHP: ```bash which php ``` ### Di cPanel/Hostinger: 1. Login ke cPanel 2. Cari menu "Cron Jobs" 3. Set interval: `* * * * *` (setiap menit) 4. Command: `/usr/bin/php /home/username/public_html/email-scheduler/cron-send-emails.php` 5. Klik "Add Cron Job" ### Di Windows (Task Scheduler): 1. Buka Task Scheduler 2. Create New Task 3. Trigger: Every 1 minute 4. Action: Start a program 5. Program: `C:\php\php.exe` 6. Arguments: `C:\xampp\htdocs\email-scheduler\cron-send-emails.php` ## Langkah 6: Test Cron Job Test manual: ```bash php cron-send-emails.php ``` Cek log: ```bash cat email_log.txt ``` ## Langkah 7: Set Permission (Linux) ```bash chmod 755 email-scheduler.html chmod 755 send-email.php chmod 755 cron-send-emails.php chmod 755 get-scheduled-emails.php chmod 755 view-scheduled-emails.html chmod 755 uploads/ chmod 644 .htaccess ``` ## Troubleshooting ### Error: "Class 'PHPMailer\PHPMailer\PHPMailer' not found" **Solusi:** - Pastikan folder PHPMailer/src/ ada dan berisi file yang benar - Cek path require di file PHP - Jika pakai Composer, jalankan: `composer install` ### Error: "SMTP connect() failed" **Solusi:** 1. Cek kredensial SMTP (username/password) 2. Coba port alternatif: - Port 465 dengan SSL - Port 587 dengan TLS 3. Cek firewall server 4. Enable "Less secure app" di email (jika Gmail) 5. Untuk Hostinger, pastikan IP server tidak diblokir ### Email masuk spam **Solusi:** 1. Setup SPF record di DNS 2. Setup DKIM di Hostinger 3. Gunakan email yang sama domain dengan SMTP 4. Hindari kata-kata spam di subject/body ### Permission denied untuk uploads/ **Solusi:** ```bash chmod 755 uploads/ chown www-data:www-data uploads/ # Linux ``` ### Cron job tidak jalan **Solusi:** 1. Cek syntax crontab: `crontab -l` 2. Cek log: `tail -f /var/log/cron` 3. Test manual: `php cron-send-emails.php` 4. Cek path PHP: `which php` ## Keamanan 1. **Jangan commit password:** ```bash echo "config.php" >> .gitignore ``` 2. **Protect file sensitif dengan .htaccess:** ```apache Order allow,deny Deny from all ``` 3. **Gunakan HTTPS** 4. **Update password secara berkala** 5. **Batasi akses folder uploads** ## Port SMTP Alternatif Jika port 465 bermasalah, gunakan port 587: ```php define('SMTP_PORT', 587); define('SMTP_SECURE', PHPMailer::ENCRYPTION_STARTTLS); ``` ## Testing Email Gunakan email testing untuk development: - Mailtrap.io (free) - MailHog (local) - SendGrid (free tier) ## Backup Backup file penting: ```bash tar -czf backup-$(date +%Y%m%d).tar.gz email-scheduler/ ``` ## Update Untuk update PHPMailer: ```bash composer update phpmailer/phpmailer ``` Atau download versi terbaru dari GitHub ## Support Jika ada masalah: 1. Cek dokumentasi: README.md 2. Cek log: email_log.txt 3. Enable debug mode di config.php 4. Hubungi support Hostinger --- ✅ **Instalasi selesai!** Sekarang Anda bisa menggunakan aplikasi Email Scheduler. Akses: - Form kirim email: `email-scheduler.html` - Lihat status email: `view-scheduled-emails.html`