Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Summative_Sam_Markey
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sam.markey
Summative_Sam_Markey
Commits
83418031
Commit
83418031
authored
May 04, 2021
by
sam.markey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHP Email script using PHPMailer
parent
d9d88ef7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
sendEmailReceipt.php
OTHER_INFORMATION/php files/sendEmailReceipt.php
+102
-0
No files found.
OTHER_INFORMATION/php files/sendEmailReceipt.php
0 → 100644
View file @
83418031
<?php
use
PHPMailer\PHPMailer\PHPMailer
;
if
(
isset
(
$_POST
[
'details'
])
&&
isset
(
$_POST
[
'emailAddress'
])
){
$allDetails
=
json_decode
(
$_POST
[
'details'
]);
$allItemData
=
json_decode
(
$_POST
[
'itemData'
]);
//checks is valid email
$email
=
$_POST
[
'emailAddress'
];
if
(
!
filter_var
(
$email
,
FILTER_VALIDATE_EMAIL
)){
echo
'invalidEmail'
;
die
;
}
else
{
//Email Address
// DETAILS
$museumName
=
$allDetails
->
museumName
;
$dateSelected
=
$allDetails
->
dateSelected
;
$timeSelected
=
$allDetails
->
timeSelected
;
$totalCost
=
$allDetails
->
totalCost
;
$amountEntered
=
$allDetails
->
amountEntered
;
$change
=
$allDetails
->
change
;
$bookingID
=
$allDetails
->
bookingID
;
$userName
=
$allDetails
->
firstname
;
$lastname
=
$allDetails
->
lastname
;
$body
=
"Dear "
.
$userName
.
"<br><br>
Here is Your Receipt.<br>Thank you for booking with World Museums! <br>
"
;
//ITEM DATA
$itemNames
=
$allItemData
->
ItemNames
;
$itemQuantity
=
$allItemData
->
ItemQuantity
;
$ItemPrices
=
$allItemData
->
ItemPrices
;
//checking to see if user has bought items
$body
.=
'<body>
<h3>----------------------ITEMS----------------------</h3><br>
<table><tr><th style="text-align: center;"><h4>Item</h4></th><th style="text-align: center;"><h4>Quantity</h4></th><th style="text-align: center;"><h4>Price</h4></th></tr>'
;
for
(
$i
=
0
;
$i
<
count
(
$itemNames
);
$i
++
){
$body
.=
'<tr><td style="text-align: center;">'
.
$itemNames
[
$i
]
.
'</td><td style="text-align: center;">'
.
$itemQuantity
[
$i
]
.
'</td><td style="text-align: center;">&pound;'
.
$ItemPrices
[
$i
]
.
".00</td></tr>"
;
}
$body
.=
'</table>'
;
$body
.=
'<h3>----------------------Details----------------------</h3>'
;
$body
.=
'<table><tr><td>Customer Name:</td><td>'
.
$userName
.
" "
.
$lastname
.
"</td></tr>"
.
"<tr><td>MuseumName:</td><td>"
.
$museumName
.
'</td></tr>'
.
"<tr><td>Date:</td><td>"
.
$dateSelected
.
'</td></tr>'
.
"<tr><td>Time Start:</td><td>"
.
$timeSelected
.
'</td></tr>'
.
"<tr><td>Total Cost:</td><td>"
.
$totalCost
.
"</td></tr>"
.
"<tr><td>Amount Entered:</td><td>"
.
$amountEntered
.
'</td></tr>'
.
"<tr><td>Change
Given:</td><td>"
.
$change
.
"</td></tr>
</table>
<h2 style='color: #A40C01;'><b>BOOKING CODE: "
.
$bookingID
.
"</b></h2>
<br> Thank you,<br> World Museums</body>"
;
PostEmail
(
$body
,
$email
,
$userName
,
$bookingID
);
}
}
else
{
echo
'check Isset '
;
}
function
PostEmail
(
$body
,
$usersEmail
,
$username
,
$bookingID
){
require
'vendor/autoload.php'
;
$mail
=
new
PHPMailer
;
$mail
->
isSMTP
();
$mail
->
SMTPDebug
=
2
;
$mail
->
Host
=
'smtp.hostinger.co.uk'
;
$mail
->
Port
=
587
;
$mail
->
SMTPAuth
=
true
;
$mail
->
Username
=
'worldmuseums@sammarkey.com'
;
$mail
->
Password
=
'PASSWORD HERE'
;
$mail
->
setFrom
(
'worldmuseums@sammarkey.com'
,
'World Museums'
);
$mail
->
addAddress
(
$usersEmail
,
$userName
);
$mail
->
Subject
=
$username
.
' Your BOOKING CODE IS: '
.
$bookingID
;
$mail
->
Body
=
html_entity_decode
(
$body
);
$mail
->
IsHTML
(
true
);
if
(
!
$mail
->
send
())
{
echo
'failure'
;
}
else
{
echo
'success'
;
}
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment