2017-04-26 4 views
-1

그래서 나는 다음과 같은 코드가 있습니다G-스위트 룸을 통해 대량 메일 PHPMAILER 보내기

while(list($i, $data_subscriber) = each($subscriber)) { 

    $email_counter = $i + 1; 
    echo ($email_counter).') '.$data_subscriber->field_1.' '.$data_subscriber->field_2.' - '.$data_subscriber->email.''."\n"; 
    flush(); 

    $language = $data_subscriber->lang; 

    $body_mail = include($template_send_newsletter); 

    $first_name_idx = $data_subscriber->field_1; 
    $last_name_idx = $data_subscriber->field_2; 

    if (mail_send(strtolower($data_subscriber->email), 
        (IsSet($first_name_idx) && IsSet($last_name_idx) ? $first_name_idx.' '.$last_name_idx : $data_subscriber->email), 
        $site_admin, 
        $site_name, 
        'Newsletter ['.date('d/m/Y', time()).']', 
        true, 
        $body_mail, 
        NULL, 
        false)) { 

     reset($data_subscriber->newsletter_item); 
     unset($log_detail); 
     $log_detail = ""; 
     while(list($j, $list_of_news_to_send) = each($data_subscriber->newsletter_item)) { 
     $log_detail = (IsSet($list_of_news_to_send->title) ? $list_of_news_to_send->title."\n" : ''); 
     $log_detail = (IsSet($list_of_news_to_send->subtitle) ? $list_of_news_to_send->subtitle."\n" : ''); 
     $log_detail = (IsSet($list_of_news_to_send->creation_date) ? $list_of_news_to_send->creation_date."\n" : ''); 
     $log_detail = "\n"; 
     } /* end while */ 

     write_newsletter_detail($data_subscriber->id_subscription, 
           $data_subscriber->email, 
           'Y', 
           $log_detail); 
    } 
    else { 
     write_newsletter_detail($data_subscriber->id_subscription, 
           $data_subscriber->email, 
           'N', 
           NULL); 
    } /* end if mail_send */ 

    } /* end while */ 

그리고 다음과 같은 기능을 내가 Gmail을 사용하여 여러 전자 메일을 보내 PHPMailer를 사용하고

function mail_send($rcpt_to,   
        $to_name,     
        $mail_from,     
        $from_name,     
        $subject,   
        $isHTML = true,    
        $body,      
        $attachment = NULL,   
        $direct_delivery = false, 
        $reply_to = NULL){ 

    $mail = new PHPmailer; 
    $mail->isSMTP(); 
    $mail->SMTPDebug = 3; 
    $mail->Debugoutput = 'html'; 
    $mail->Host = 'smtp.gmail.com'; 
    $mail->Port = 587; 
    $mail->SMTPSecure = 'tls'; 
    $mail->SMTPAuth = true; 
    $mail->Username = "[email protected]"; 
    $mail->Password = "password"; 
    $mail->Timeout = 3600; 
    $mail->addAddress(trim($rcpt_to), trim($to_name)); 
    $mail->setFrom($mail_from,$from_name); 
    $mail->Subject = $subject; 
    $mail->Body = $body; 

    if ($isHTML) { 
     $mail->IsHTML(true); 
     $mail->AltBody = strip_tags($mail->Body); 
    } 
    if (IsSet($attachment)) { 
     $mail->AddAttachment($attachment['tmp_name'], $attachment['name']); 
    } 
    if (IsSet($reply_to)) { 
     $mail->AddReplyTo($reply_to); 
    } 
    if (!$mail->send()) { 
     return false; 
    } else { 
     return true; 
    } 
    } 

SMTP 서버. 나는 4 개의 파일을 포함하고 있지만 뉴스 레터를 보내는 코드는 거의 같다. 내 파일 중 하나가 (~ 60 명의받는 사람에게) 모든 전자 메일을 보내고 있습니다 다른 3 개의 파일은 각각 하나의 전자 메일을 ~ 600 명의받는 사람에게 보내야합니다. 여기에서 문제가 발생하면 전자 메일의 절반이 전송되고 다른 전자 메일은 전송되지 않습니다. 스크립트를 실행했지만 이번에는 수신자 수가 적 으면 처음으로 전자 메일을받지 못했습니다. 보내는 중입니다.

나는 내 도메인에서 GMAIL을 사용하고 있습니다. 그래서 나는 어떤 한계도 넘지 않는다.

이 문제가 발생할 수있는 이유는 무엇입니까? 어떤 아이디어? 고맙습니다.

UPDATE ** 내가이 오류를받을 전송되는 일부 이메일 후

SERVER -> CLIENT: 454 4.7.0 Too many login attempts, please try again later. e11sm950198edd.68 - gsmtp 

. 어떤 아이디어?

UPDATE ***

나는 그것이 SMTP 서버에 모든 전자 메일을 연결하지 그래서 코드를 변경 관리
$mail = new PHPMailer; 
    $mail->isSMTP(); 
    $mail->SMTPDebug = 3; 
    $mail->Host = 'smtp.gmail.com'; 
    $mail->SMTPAuth = true; 
    $mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead 
    $mail->Port = 465; 
    $mail->SMTPSecure = 'ssl'; 
    $mail->Username = "[email protected]"; 
    $mail->Password = "password"; 
    $mail->setFrom($site_noreply, $site_name); 
    $subjectnewsletter = 'Newsletter ['.date('d/m/Y', time()).']'; 
    $mail->Subject = $subjectnewsletter; 
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; 

    reset($subscriber); 
    while(list($i, $data_subscriber) = each($subscriber)) { 
    $email_counter = $i + 1; 
    echo ($email_counter).') '.$data_subscriber->field_1.' '.$data_subscriber->field_2.' - '.$data_subscriber->email.''."\n"; 
    flush(); 
    $language = $data_subscriber->lang; 
    $first_name_idx = $data_subscriber->field_1; 
    $last_name_idx = $data_subscriber->field_2; 
    $fullname = $first_name_idx.' '.$last_name_idx; 

    $bodymail = include($template_send_newsletter); 
    $mail->msgHTML($bodymail); 
    $mail->addAddress($data_subscriber->email, $fullname); 
    reset($data_subscriber->newsletter_item); 
    unset($log_detail); 
    $log_detail = ""; 
    while(list($j, $list_of_news_to_send) = each($data_subscriber->newsletter_item)) { 
    $log_detail = (IsSet($list_of_news_to_send->title) ? $list_of_news_to_send->title."\n" : ''); 
    $log_detail = (IsSet($list_of_news_to_send->subtitle) ? $list_of_news_to_send->subtitle."\n" : ''); 
    $log_detail = (IsSet($list_of_news_to_send->creation_date) ? $list_of_news_to_send->creation_date."\n" : ''); 
    $log_detail = "\n"; 
    } /* end while */ 
    if (!$mail->send()) { 
    write_newsletter_detail($data_subscriber->id_subscription, 
          $data_subscriber->email, 
          'N', 
          NULL); 
     echo $mail->ErrorInfo; 
     break; //Abandon sending 
    } else { 

    write_newsletter_detail($data_subscriber->id_subscription, 
          $data_subscriber->email, 
          'Y', 
          $log_detail); 
     echo "Message sent"; 
    } 
    $mail->clearAddresses(); 
    $mail->clearAttachments(); 
    } /* end while */ 

.

SMTP server error: MAIL FROM command failed 
+3

아마도 스팸을 막는 속도 제한이 있습니까? –

+1

"내 도메인에서 GMAIL을 사용하고 있습니다. 따라서 제한을 초과하지는 않습니다." 여전히 한계가 있습니다. https://support.google.com/a/answer/166852?hl=ko 실제 뉴스 레터 시스템을 사용하십시오. – ceejayoz

+1

잘 오류가 잘못되었다고 분명히 말하면 모든 이메일에 다시 로그인하십시오 – Peter

답변

0

당신은 하나 개 이상의 연결을 사용하는 MTA을 사용할 필요가이를 이미 설치 당신이에 연결하는 서버의 한계를 존중 : 그것은 93 이메일을 전송 한 후 는하지만 지금은 follosing의 오류가 발생합니다. 이 시점에서 연결하려는 서버의 한계를 초과하려고 시도하고 있으며 Google과 같은 회사는 너무 많은 연결을 싫어하거나 브로드 캐스트를 위해 메일 서버를 사용하지 않습니다.

숫자가 겸손한 경우 mail sending service을 찾으십시오. 상당한 양의 이메일을 보내면 MTA를 구입하고 호스팅하는 것을 고려하십시오.

+0

그래, 나도 알아,하지만 전자 메일을 보내는 데 G-Suite 전자 메일 서비스를 사용할 때 나는 총 2000 개의 메시지를 하루에 보낸다. 내 스크립트는 하루에 약 1400-1500 개의 메시지를 보냈습니다. 그래서 이론적으로 나는 그들을 보낼 수 있어야합니다. –

+0

'$ site_noreply'와'$ side_name'을 설정하고 유효한 이메일 주소를'$ site_noreply '하고 있습니까? 즉, 반송 된 이메일이 거기에 갈 수 있고 검색 할 수 있다는 뜻입니까? 또한 gsuite를 사용하고 있음을 나타 내기 위해 질문을 업데이트했습니다. 어떤 사람들은 Gmail 계정을 사용하여 Google을 통해 이메일을 보내 메일을 발송하고 한계에 도달했습니다. –

+0

예 $ site_noreply은 유효한 이메일 주소입니다. –