Well, i am having an issue that i really don't have any clue and already have read everything that i could find about.
I have a code in php using phpMailer that using gmail, the emails arrives where they should when the php archive is opened by the terminal, but, when i upload to the server the emails just arrive at the final destiny if they never arrive at the mail.
in my case i want to send to an email exemple@companyName.io, that is a gmail email as well.
i just cant figure it out why the emails just work arriving at the final destiny when they are being send to a hotmail or gmail account(exemple@gmail.com) but to a exemple@companyName.io(that is a gmail as well) does not work.
Thanks in advance!
PHP code:
<?php
date_default_timezone_set('Etc/UTC');
require 'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587; //same problem with other ports
$mail->SMTPSecure = 'tls'; //same problem with ssl
$mail->SMTPAuth = true;
$mail->Username = "exemple@gmail.com";
$mail->Password = "password";
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
$mail->setFrom($email, $name);
$mail->addAddress('exemple@CompanyName.io', 'exemple Name');
$mail->Subject = 'Contact';
$mail->Body = $message;
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
EDIT:
i found out the answer, my server was from godaddy, so :
GoDaddy
Popular US hosting provider GoDaddy imposes very strict (to the point of becoming almost useless) constraints on sending email. They block outbound SMTP to ports 25, 465 and 587 to all servers except their own. This problem is the subject of many frustrating questions on Stack Overflow. If you find your script works on your local machine, but not when you upload it to GoDaddy, this will be what's happening to you. The solution is extremely poorly documented by GoDaddy: you must send through their servers, and also disable all security features, username and password (great, huh?!), giving you this config for PHPMailer:
$mail->isSMTP();
$mail->Host = 'relay-hosting.secureserver.net';
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;
GoDaddy also refuses to send with a From add
ress belonging to any aol, gmail, yahoo, hotmail, live, aim, or msn domain (see their docs). This is because all those domains deploy SPF and DKIM anti-forgery measures, and faking your from address is forgery.
You may find it easier to switch to a more enlightened hosting provider.