moprocto's avatar

Remove "on behalf of" when sending mail with mailgun

I send simple emails with Mailgun's SDK, but when I view the emails with outlook, it has this stuck at the top:

[email protected] on behalf of Toy Story <[email protected]>

the domain of the web server is portal.cowboy.org but emails from the server are [email protected]

my Mailgun code looks like this

Mail::send(['html' => 'emails.generic'], $data, function($message) use ($subject, $email, $name){
            $message->to($email, $name)
            ->subject("$subject");
                $message->from("[email protected]",'Toy Story');
            });

What do I need to do to make it so that the user sees:

Toy Story <[email protected]>

?

0 likes
3 replies
moprocto's avatar
moprocto
OP
Best Answer
Level 1

ugh.... here's the solution

Mail::send(['html' => 'emails.generic'], $data, function($message) use ($subject, $email, $name){
            $message->to($email, $name)
            ->subject("$subject");
                $message->from("[email protected]",'Toy Story');
$message->sender("[email protected]",'Toy Story');
            });

there's no documentation (that I could find) stating you have to add ->sender to remove the "on behalf of".

3 likes
eddieoscar's avatar

hello, could you please tell me where to EDIT the code?

1 like
Xeropex's avatar

Hello,

I know this is an old post, but I was searching for a proper solution myself while using a Mailable class. You may use the example below.

use Symfony\Component\Mime\Email;

public function envelope()
    {
        return new Envelope(
			// your code
            using: [
                function (Email $message) {
                    $message->sender("[email protected]"); // Change this line to your emailaddress
                },
            ]
        );
    }
1 like

Please or to participate in this conversation.