2

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.

Catarina Nogueira
  • 1,024
  • 2
  • 12
  • 28

1 Answers1

1

I guess you are missing IsSMTP() setting:

$mail = new PHPMailer();
$mail->IsSMTP();
Sooraj
  • 412
  • 4
  • 11
  • i have already tried this but when i write and run it appears this error: **SMTP ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting** So, i saw at this post that i can take if off: [http://stackoverflow.com/questions/39445338/phpmailer-mail-error-smtp-connect] Thanks a lot for anwering, i will read more about taking off the $mail->IsSMTP() ˆˆ – Catarina Nogueira Feb 09 '17 at 17:47
  • you help a lot, really! tx a lot! the edit with the correct answer is at the question on top!! :D :D – Catarina Nogueira Feb 09 '17 at 18:01