Address in mailbox given [] does not comply with RFC 2822, 3.6.2. when email is in a variable

后端 未结 13 2234
执笔经年
执笔经年 2020-12-16 09:52

I have a correct email address. I have echoed it, but when I send it, I get the following error:

 Address in mailbox given [] does not comply with RFC 2822,          


        
相关标签:
13条回答
  • 2020-12-16 10:09

    Make sure your email address variable is not blank. Check using

    print_r($variable_passed);
    
    0 讨论(0)
  • 2020-12-16 10:10

    [SOLVED] Neos/swiftmailer: Address in mailbox given [] does not comply with RFC 2822, 3.6.2

    Exception in line 261 of /var/www/html/vendor/Packages/Libraries/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php: Address in mailbox given [] does not comply with RFC 2822, 3.6.2.

    private function _assertValidAddress($address)
    {
        if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D',
            $address)) {
            throw new Swift_RfcComplianceException(
                'Address in mailbox given ['.$address.
                '] does not comply with RFC 2822, 3.6.2.'
                );
        }
    }
    

    https://discuss.neos.io/t/solved-neos-swiftmailer-address-in-mailbox-given-does-not-comply-with-rfc-2822-3-6-2/3012

    0 讨论(0)
  • 2020-12-16 10:11

    These error happen when the $email variable is empty or sometimes when the mail doesn´t exists, try with an existing mail

    0 讨论(0)
  • 2020-12-16 10:15

    I have faced the same problem and I have fixed. Please make sure some things as written bellow :

       Mail::send('emails.auth.activate', array('link'=> URL::route('account-activate', $code),'username'=>$user->username),function($message) use ($user) {
                            $message->to($user->email , $user->username)->subject('Active your account !');
    
                        });
    

    This should be your emails.activation

        Hello {{ $username }} , <br> <br> <br>
    
        We have created your account ! Awesome ! Please activate by clicking the   following link <br> <br> <br>
       ----- <br>
          {{ $link }} <br> <br> <br>
           ---- 
    

    The answer to your why you can't call $email variable into your mail sending function. You need to call $user variable then you can write your desired variable as $user->variable

    Thank You :)

    0 讨论(0)
  • 2020-12-16 10:16
     Mail::send('emails.activation', $data, function($message){
            $message->from('email@from', 'name');
            $message->to($email)->subject($subject);
        });
    

    I dont know why, but in my case I put the from's information in the function and it's work fine.

    0 讨论(0)
  • 2020-12-16 10:17

    Your email variable is empty because of the scope, you should set a use clause such as:

    Mail::send('emails.activation', $data, function($message) use ($email, $subject) {
        $message->to($email)->subject($subject);
    });
    
    0 讨论(0)
提交回复
热议问题