0

I have a page in my website (contacts.html) that as a form to send emails to a specific fount (email that a create to receive those emails from different founts).I'm using Postmark as host.

this is the code to send email (using phpmailer, and already have the html form):

if(isset($_POST['send'])){

$name = $_POST['sendName'];
$email = $_POST['sendEmail'];
$subject = $_POST['sendSubject'];
$message = $_POST['sendMessage'];
$password = $_POST['sendPass'];

require_once('phpmailer/class.phpmailer.php');
require_once('phpmailer/class.smtp.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.postmarkapp.com";
$mail->Port = 2525; // or 587 //or 25
$mail->IsHTML(true);
$mail->Username = $email;
$mail->Password = $password;
$mail->From = $email;
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddAddress("teste2x2016@gmail.com","jon");

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

}

so the problem is I pass the email and the password of that same email (when someone want to send email to the one that I create), and the code fail like this:

SMTP -> ERROR: Password not accepted from server: 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6 SMTP -> ERROR: RCPT not accepted from server: 454 4.7.1 : Relay access denied SMTP Error: The following recipients failed: teste2x2016@gmail.com Mailer Error: SMTP Error: The following recipients failed: teste2x2016@gmail.com SMTP server error: 4.7.1 : Relay access denied

Adriano Maia
  • 103
  • 6
  • Your authentication credentials (password, username) is wrong. – Christian Sep 11 '16 at 06:45
  • I tried sometimes and i verify if i insert the password right.... So that's not the problem..... I don't know if as to do with security or not...... If a sent emails to the same email ( like email to myself) it works but i want to send emails from differents sources to one that i create – Adriano Maia Sep 11 '16 at 06:50
  • Oh, I see it. You don't know how mails work. You need to get the MX-Record of the domain the user enters within the form and try to log in there. – Christian Sep 11 '16 at 06:52
  • And how can i get the mx-record? – Adriano Maia Sep 11 '16 at 07:00
  • http://php.net/manual/en/function.dns-get-record.php – Christian Sep 11 '16 at 07:01

0 Answers0