2014-02-27 1 views
0
내가 Swiftmailer를 사용하는 기존 응용 프로그램을 해결하기 위해 노력하고

필드,하지만 난 방법이 오류를 수정하는 방법 아무 생각이 :Swiftmailer 발신자는 오류

PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [[email protected]] does not comply with RFC 2822, 3.6.2.' in /opt/lampp/htdocs/sptoolkit/spt/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php:308\nStack trace: 
    \n#0 /opt/lampp/htdocs/sptoolkit/spt/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php(238): Swift_Mime_Headers_MailboxHeader->_assertValidAddress('[email protected]') 
    \n#1 /opt/lampp/htdocs/sptoolkit/spt/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php(96): Swift_Mime_Headers_MailboxHeader->normalizeMailboxes(Array) 
    \n#2 /opt/lampp/htdocs/sptoolkit/spt/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php(60): Swift_Mime_Headers_MailboxHeader->setNameAddresses(Array) 
    \n#3 /opt/lampp/htdocs/sptoolkit/spt/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(581): Swift_Mime_Headers_MailboxHeader->setFieldBodyModel(Array) 
    \n#4 /opt/lampp/htdocs/sptoolkit/spt/includes/swiftmailer/lib/cl in /opt/lampp/htdocs/sptoolkit/spt/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php on line 308, referer: http://localhost:8080/sptoolkit/spt/campaigns/?c=9&responses=true 

오류에 대한 추가 정보는 여기에서 찾을 수 있습니다 : https://tools.ietf.org/html/rfc2822#section-3.6.2

여기에 발신자 필드

if (! isset ($relay_host) AND ! isset ($relay_username) AND ! isset ($relay_password)) { 
     //parse out the domain from the recipient email address 
     $domain_parts = explode ("@", $current_target_email_address); 
     $domain = $domain_parts[1]; 

    //get MX record for the destination 
    getmxrr ($domain, $mxhosts); 

    // 
    //create the transport 
    if(isset($ssl) && $ssl == "no"){ 
     $transport = Swift_SmtpTransport::newInstance ($mxhosts[0], 25);  
    }else{ 
     $transport = Swift_SmtpTransport::newInstance ($mxhosts[0], 25, 'tls');  
    } 

} 
//Create the Mailer using your created Transport 
    $mailer = Swift_Mailer::newInstance ($transport); 

    //To use the ArrayLogger 
    $logger = new Swift_Plugins_Loggers_ArrayLogger(); 
    $mailer -> registerPlugin (new Swift_Plugins_LoggerPlugin ($logger)); 

    //Create a message 
    $message = Swift_Message::newInstance ($subject) 
      -> setSubject ($subject) 
      -> setFrom (array ($sender_email => $sender_friendly)) 
      -> setReplyTo ($reply_to) 
      -> setTo (array ($current_target_email_address => $fname . ' ' . $lname)) 
      -> setContentType ($content_type) 
      -> setBody ($message) 
    ; 

    //specify that the message has been attempted 
    mysql_query ("UPDATE campaigns_responses SET sent = 1 WHERE response_id = '$current_response_id'"); 

    //Send the message 
    $mailer -> send ($message, $failures); 

    //store logs in database 
    $mail_log = $logger -> dump(); 
    $mail_log = nl2br (htmlentities ($mail_log)); 
    mysql_query ("UPDATE campaigns_responses SET response_log='$mail_log' WHERE response_id = '$current_response_id'"); 

    //get current datetime 
    $sent_time = date ('Y-m-d H:i:s'); 

    //specify that message is sent and timestamp it 
    mysql_query ("UPDATE campaigns_responses SET sent = 2, sent_time = '$sent_time' WHERE response_id = '$current_response_id'"); 

    //specify if there was a failure 
    if (count ($failures) > 0) { 
     mysql_query ("UPDATE campaigns_responses SET sent = 3 WHERE response_id = '$current_response_id'"); 
    } 

주를 설정하는 코드입니다! 유효한 전자 메일 주소를 사용하고 있습니다.

답변

0

특히이 오류는 경험이 없습니다. 그러나 빠른 Google 검색은 다음 두 가지 옵션을 충족 시켰습니다.

  1. mailaddress는 실제 메일 주소입니까? Swiftmailer가 domaindns 검사와 같은 몇 가지 항목을 확인하십시오.
  2. RFC 2822 검사를 해제하십시오. 제 생각에는 최선의 선택이 아닙니다.

https://github.com/swiftmailer/swiftmailer/issues/382

+0

내가 사용하고 이메일 주소는 실제 이메일 ADRESS입니다. 나는 이미 RFC 체크를 끄려 고했지만, 여전히 qdditional 아파치 에러가없는 메일은 없다. – David