PHP Mail未发送到外部电子邮件

时间:2015-08-11 18:24:11

标签: php email emailrelay

我有以下邮件功能,我用它来发送电子邮件。它适用于我发送的同一个电子邮件地址。但是当我更改“$ to”的电子邮件地址时,它没有被发送,也没有给出任何错误。

 <?php 

        if(!isset($_SESSION)) 
        { 
            session_start(); 
        }

    require 'PHPMailer/PHPMailerAutoload.php';

    $port = 587;
    $host = "mail.gmx.com";
    $security = 'tls';
    $username = "xxxxxx@gmx.com";
    $password = "xxxxxx";

      function sendPaymentApprovalMailToPayee($to,$receiver,$payno,$amount){

global $port,$host,$security,$username,$password;
        $to = "xxxxxx@gmx.com"; //When you change this to an outside email the mail doesn't get sent
        $from = "xxxxxxx@gmx.com";;
        $subject = "Payment Approved #".$payno;
        $message = "<p>Dear ".$receiver." ,</p>
    <p>We are sending this mail to confirm that the payment of Rs.".$amount." (Pay No : #".$payno." ) has been approved and successfully transferred to your account.</p>
    <p>Thanks & Best Regards,<br> Online Payment System - Team.</p>";

       $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 = $security; // secure transfer enabled REQUIRED for GMail
    $mail->Host = $host;
    $mail->Port = $port; // or 587
    $mail->IsHTML(true);
    $mail->Username = $username;
    $mail->Password = $password;
    $mail->SetFrom($from);
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->AddAddress($to);
     if(!$mail->Send())
        {
        //echo "Mailer Error: " . $mail->ErrorInfo;
        return false;
        }
        else
        {
            return true;
        //echo "Message has been sent";
        }



      }

      ?>

gmx邮件设置

服务器设置

POP3是“邮局协议版本3”的缩写。 POP3直接从服务器检索邮件到邮件程序,然后删除服务器上的邮件。

传入: 服务器:pop.gmx.com 港口:995 加密:SSL (如果“SSL”不可用,您只需启用“加密”功能。)

传出: 服务器:mail.gmx.com 港口:587 加密:STARTTLS 如果“STARTTLS”不可用,请使用协议“TLS”。如果该选项不可用,只需激活“加密”选项。

0 个答案:

没有答案