I see a few issues without testing that might fix the problem.
All of the issues are on lines 466-489.
466-474 is repeated code and have bad credentials. That code should just be deleted.
Then the code from 475-481 is in the wrong place:
<?php
if ($eCart1->IsEmpty()) {
$eCart1->redirStr = "cart.php";
$eCart1->cartAction = "RedirectIfEmpty";
}
?>
That code should be moved up to the top below line 13.
The code on lines 482-484:
<?php
$eCart1->GetContent();
?>
is also repeated and can be deleted.
Then the main problem is the code on lines 484 to 489:
<?php
// WA eCart Redirect
if ($eCart1->redirStr != "") {
header("Location: ".$eCart1->redirStr);
}
?>
That is causing the page to redirect before the insert to the database. It should be moved down so it is just before the html code begins.
The email not sending may not be related to any of that. I'd start by debugging the credentials by creating a blank page that sends an email with the same credentials. You can turn on debugging to get any error messages from the SMTP server in the email server behavior settings.
Try all that and post back with where it gets you and I can try helping more if necessary.