I have the following mail function which I am using to send an email. It works fine to the same email address that I am sending from. But when I change the email address of "$to" it is not being sent and doesn't give any error.
<?php
if(!isset($_SESSION))
{
session_start();
}
require 'PHPMailer/PHPMailerAutoload.php';
$port = 587;
$host = "mail.gmx.com";
$security = 'tls';
$username = "[email protected]";
$password = "xxxxxx";
function sendPaymentApprovalMailToPayee($to,$receiver,$payno,$amount){
global $port,$host,$security,$username,$password;
$to = "[email protected]"; //When you change this to an outside email the mail doesn't get sent
$from = "[email protected]";;
$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 mail settings
Server Settings
POP3 is an abbreviation for "Post Office Protocol Version 3". POP3 retrieves mails directly from a server into a mail program and deletes the mails on the server afterwards.
Incoming: Server: pop.gmx.com Port: 995 Encryption: SSL (If "SSL" is not available, you simply have to enable the "Encryption" function.)
Outgoing: Server: mail.gmx.com Port: 587 Encryption: STARTTLS If "STARTTLS" is not available, please use the protocol "TLS". If that option is not available, simply activate the option "Encryption".