Skip to content

Commit

Permalink
Portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
arunp77 committed Oct 6, 2023
1 parent aafe0d5 commit fc3fec5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Configure SMTP
run: |
echo "::add-mask::$GMAIL_PASSWORD"
echo "::set-env name=SMTP_USERNAME::${{ secrets.GMAIL_USERNAME }}"
echo "::set-env name=SMTP_PASSWORD::${{ secrets.GMAIL_PASSWORD }}"
- name: Run PHP Script
run: |
php your-script.php
env:
SMTP_USERNAME: ${{ env.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ env.SMTP_PASSWORD }}
8 changes: 8 additions & 0 deletions forms/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
'port' => '587'
);
*/
$contact->smtp = array(
'host' => 'smtp.gmail.com',
'username' => $_ENV['GMAIL_USERNAME'], // Use an environment variable for Gmail username
'password' => $_ENV['GMAIL_PASSWORD'], // Use an environment variable for Gmail password
'port' => '587',
'encryption' => 'tls' // Use TLS encryption for Gmail
);


$contact->add_message( $_POST['name'], 'From');
$contact->add_message( $_POST['email'], 'Email');
Expand Down
24 changes: 24 additions & 0 deletions forms/process_contact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];

$to = "arunp77@gmail.com"; // Your email address
$subject = "Contact Form Submission: $subject";
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";

$mailBody = "Name: $name\n";
$mailBody .= "Email: $email\n";
$mailBody .= "Subject: $subject\n\n";
$mailBody .= "Message:\n$message";

if (mail($to, $subject, $mailBody, $headers)) {
echo "success"; // You can customize this response message
} else {
echo "error"; // You can customize this response message
}
}
?>

0 comments on commit fc3fec5

Please sign in to comment.