Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rretzko's avatar
Level 15

Universal 'to' not working with MailTrap.io

Hi - I'm running into a problem getting Laravel to send emails to MailTrap. A secondary problem is that the system seems to be ignoring my Universal 'to' setting.

My production email will be going through PostMark, from which the error messages appears to be originating, but I don't have my dev environment configured to go to PostMark, and the error message references the user's actual email domain (hotmail.com) rather than the Universal 'to' I have configured.

All assistance is appreciated!

Error Message:

{"ErrorCode":412,"Message":"While your account is pending approval, all recipient addresses must share the same domain as the 'From' address. The domain of the 'From' address is 'mfrholdings.com', but you are attempting to send email to the following domain: 'hotmail.com'."}

.env


MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=#######
MAIL_PASSWORD=#######
MAIL_ENCRYPTION=null
[email protected]
MAIL_FROM_NAME="Rick Retzko"

config/mail.php


return [

    'driver' => env('MAIL_DRIVER', 'smtp'), //default

    'host' => env('MAIL_HOST', 'smtp.mailgun.org'), //default
    
    'port' => env('MAIL_PORT', 587),

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'), //default
        'name' => env('MAIL_FROM_NAME', 'Rick Retzko'),   //default
    ],
    
    'port' => env('MAIL_PORT', 587),

    'reply_to' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'), //default
        'name' => env('MAIL_FROM_NAME', 'Rick Retzko'),   //default
    ],

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('MAIL_USERNAME'), //default

    'password' => env('MAIL_PASSWORD'), //default

    'sendmail' => '/usr/sbin/sendmail -bs',

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

    'log_channel' => env('MAIL_LOG_CHANNEL'),
    
    'postmark' => ['token' => "d9af2667-ffbc-4806-ad7e-a37f3e468f03"],
   
    'to' => ['address' => "[email protected]",
             'name' => 'Development'
        ],

];

app/Mail/file

use App\School;
use App\Student;
use App\Teacher;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class newStudent extends Mailable
{
    use Queueable, SerializesModels;

    private $school;
    private $student;
    private $teacher;
    
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(School $school, Student $student, Teacher $teacher)
    {
        $this->school = $school;
        $this->student = $student;
        $this->teacher = $teacher;
    }

    /**
     * Build the message.
     *
     * uses global MAIL_FROM_ADDRESS and MAIL_FROM_NAME for "From" and "Reply-To"
     * 
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.newstudent')
                ->text('emails.newstudent_plain')
                ->with([
                    'teacher_name' => $this->teacher->person->fullName,
                    'student_name' => $this->student->person->fullName,
                    'school_name' => $this->school->name,
                ]);
    }
}
0 likes
3 replies
Ladislao's avatar

Hi, if you modified your ENV file, you might try runing

php artisan config:cache

sidneygijzen's avatar
Level 19

This bit in the error message

While your account is pending approval, all recipient addresses must share the same domain as the 'From' address.

suggests to me that verification of your account with Mailtrap is needed before you can fully use their service. Usually Mailtrap sends a message with a verification link to the email address you registered with.

Please or to participate in this conversation.