0

First of I don't know if I should upload any code for the question. The reason is I consider it general. But any recomendation is welcome.

Now, I have a php script, using phpmailer to send email confirmation upon signup. It working perfectly on localhost. But when I transfer it to remote it doesnt replicate or send out email.

Any idea why is this so? I haven't worked on Mailer again. Thank you.

Shammir
  • 927
  • 4
  • 17
  • 32
  • Are you using any external SMTP (which is the preferred way) or are you using sendmail or similar to sent the emails? – M. Eriksson Nov 19 '17 at 08:22
  • This is most likely because your hosting provider is blocking outbound SMTP. Go through the procedures in the PHPMailer troubleshooting guide. Also, search before you post - this exact question has been asked many times before. – Synchro Nov 20 '17 at 10:35
  • Possible duplicate of [SMTP configuration not working in production](https://stackoverflow.com/questions/39524110/smtp-configuration-not-working-in-production) – Synchro Nov 20 '17 at 10:36

2 Answers2

0

You have to configure SMTP on local then only you can send mail from local machine,

Take reference : How to send email from localhost WAMP Server to send email Gmail Hotmail or so forth?

Thanks.

Saurabh
  • 131
  • 6
0

You need understand how smtp server works first.

You can get mx hosts for recipient email-domain from dns and then send email to this host on port 25 (always) without own smtp server (open port 25 on firewall on local firewall): How to, using PHP, ping an SMTP server and check MX records? or with phpMailer.

Get domain dns mx records/hostnames (PHP)

function getMX($hostname = "boo.xx", $show = 0){
    if(dns_get_mx($hostname, $mxhosts, $weights)) {
        $i = 0;
        $mxList = NULL;
        foreach($mxhosts as $key => $host) {
            if($show == 1) echo "Hostname: $host (Weight: {$weights[$key]}) <br>";
            $ip = gethostbyname($host);
            if($show == 1) echo "IP " . $ip . "\n<br>";
            if($show == 1) echo "IP " . gethostbyaddr($ip) . "\n<br>";
            $mxList[$i]['host'] = $host;
            $mxList[$i]['ip'] = $ip;
            $mxList[$i]['weight'] = $weights[$key];
            $i++;
        }
        return $mxList;
    } else {
        echo "Could not find any MX records for $hostname\n";
    }
}
bananos
  • 11
  • 2