require_once('phpmailer/class.phpmailer.php');
function smtpmailer($to,$from,$subject,$body) {
define('GUSER', 'xxx'); // Gmail username
define('GPWD', 'xxx'); // Gmail password
printf("list:".$to);
$recipient = array ($to);
global $error;
$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 = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, "Bank Negara");
$mail->Subject = $subject;
$mail->Body = $body;
foreach ($recipient as $email){
$mail->AddAddress($email);
}
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
를 제공해야합니다 나는 그런 형식의 전자 메일 주소를 보유하는 문자열을 전달하고있다 오류가 발생했습니다 잘못된 주소 :하지만 문자열 출력을 직접 다음과 같이 전달하면 :PHP 메일러 당신의 이메일 주소를 적어도 하나의
$recipient = array ('[email protected]','[email protected]');
잘 작동합니다. 내 $ $를이 $ recipient 배열에 어떻게 전달해야합니까?
당신의 이 게시물의 Gmail 계정/비밀번호 정보. 이 암호는 즉시 변경해야합니다. –