Q:

Mail function in PHP

I'm using PHP for sending an e-mail. The values in the e-mail are depending on the inputs of a form. But for some reason, the mail is suddenly not sending. It did before. What's wrong with my code?
Orders are placed correctly in the database, so no error there.
if ($order->addOrder($_DB)) {
$user       = "SafetyCam.be";                               
$verzonden      = FALSE;                            

    $firstname = $_POST['firstname']; 
    $lastname   = $_POST['lastname'];
    $address    = $_POST['address'];
    $zip        = $_POST['zip'];
    $place      = $_POST['place'];
    $country    = $_POST['country'];
    $phone      = $_POST['phone'];
    $email      = $_POST['email'];
    $twogig = $_POST['vn_qty'];
    $fourgig    = $_POST['ja_qty'];
    $total      = $_POST['total'];

    $totaal = (($twogig * 50) + ($fourgig *80) + 2.5);

    $headers    = 'From: info@something.be';

$to     = 'me@gmail.com';
$subject    = 'Bevestiging bestelling';
$message    = 'Hello $firstname,

        You placed the following order on our website.

        - $twogig x 2GB SafetyCams ordered
        - $fourgig x 4GB SafetyCams ordered
        + shippingcosts (2,5 EUR)

        The total cost for this order amounts to $totaal EUR.

        Your products will be delivered as quickly as possible after receipt of your payment. 
        Please transfer the order amount of $totaal EUR into account X.                     

        After payment, the products will be sent to the following address:

        $firstname $lastname
        $address
        $zip $place
        $country

        We hope you will be very happy with your purchase.

        Sincerely yours";

     if (mail($to, $subject, $message, $headers)) {
                $verzonden  = TRUE;
                $feedback    = '<div class="feedbackheader">Thanks</div><br / >';

            } else {
                $verzonden  = FALSE;
                $feedback    = '<div class="feedbackheader">Error!</div>';              }
            } 
        else {
            $feedback    = '<div class="feedbackheader">Error!</div>';
        }
}

A:

Why do you open your mail $message with a single quote and end it in a double quote.
You should open and end with both double quotes, especially since you use PHP variables inside.
$message    = 'Hello $firstname"; //Wrong

$message = "Hello $firstname"; // Works

A:

I use SwiftMailer:
require_once('../lib/swiftMailer/lib/swift_required.php');
function sendEmail(){
  //Sendmail
  $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

  //Create the Mailer using your created Transport
  $mailer = Swift_Mailer::newInstance($transport);

  $body="Dear $fname,\n\nYour job application was successful. \n\nYours,\n\nEamorr\n\n\n\n\n\n\n";

  //Create a message
  $message = Swift_Message::newInstance('Subject goes here')
    ->setFrom(array($email => "no-reply@yourdomain.com"))
    ->setTo(array($email => "$fname $lname"))
    ->setBody($body);

  //Send the message
  $result = $mailer->send($message);
}

