Search code examples
laravelsmtpgmail

Enter the wrong email address, the email will still go to the correct email address


If I am sending the email to "[email protected]", it will still send to "[email protected]"

Here is my code, please tell me what I'm doing wrong?

$single_email = $this->single_email;
        try {
            Mail::send('welcome_mail',['user'=>$single_email], function($message) use($single_email) {
                
                $name = "Name";

                if($single_email->first_name){
                    $name = $single_email->first_name;
                }
                $message->to($single_email->email,$name)
                            ->subject("Subject")
                            ->from('[email protected]',"From")
                            ->replyTo('[email protected]',"Reply to");
            });
            MailSend::where('id',$single_email->id)->update(['is_sent'=>3]);
        } catch (\Exception $e) {
            MailSend::where('id',$single_email->id)->update(['error'=>$e->getMessage()]);
        }

Thanks.


Solution

  • That is how emails work. Gmail and most providers allow you multiple "sibling" emails by appending + to the end. For example, [email protected] and [email protected] will both end up at [email protected] - One of many things people use this is to track which service leaked your email. E.g. [email protected], if you start getting spam emails to [email protected], you will know they revealed it.

    So, there is nothing wrong with your code.