I'm running locally from my mac, when the info is entered and I click send the email is not showing up in the outgoing email account in sent mail, and not showing up in the incoming email either; spam folder included. There is not an error echo. The echo states the message is sent without error. I'm at a loss here. By the way I am a newbie at coding so please be gentle and explain in depth. I appreciate any help that anyone might be able to provide. Here is my code.
<form method="post" enctype="multipart/form-data">
<p>
E-Mail:
</p>
<p>
<input type="text" name="receiver" />
</p>
<p>
Subject:
</p>
<p>
<input type="text" name"subject" />
</p>
<p>
Note:
</p>
<p>
<textarea name="message"></textarea>
</p>
<p>
Select Photo:
<input type="file" name="file" />
</p>
<input type="submit" name="submit" value="Send Email" />
</form>
<?php
if (isset($_POST['submit'])) {
require "php-mailer-master/PHPMailerAutoload.php";
$mail = new PHPMailer;
try {
$sender = "????????????@gmail.com";
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '$sender';
$mail->Password = '????????????';
$mail->SMTPSecure = 'tls';
$mail->Port = '587';
$mail->isHTML();
$mail->setFrom($sender, 'Mailer');
$mail->addAddress($_POST["receiver"]);
$mail->addAttachment ($file_name);
$mail->isHTML(true);
$mail->Subject = $_POST["subject"];
$mail->Body = $_POST["message"];
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
}
?>