How to set mail from-name?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
columbo
Advanced
Posts: 125
Joined: 09 Oct 2019, 09:42

How to set mail from-name?

Post by columbo » 06 Nov 2023, 16:51

Hi,

I'm trying to set the mail "from-name" eg. for the payment mail
already set the correct name:

1. in .env MAIL_FROM_NAME

2. in config/mail.php:
'from' => [
'name' => '...',
],

3. and in config/shop.php
'email' => [
'from-name' => '...',
],

but this had no effect - why? what is missing or where else do I have to set the mail from-name?

Thank you

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: How to set mail from-name?

Post by aimeos » 10 Nov 2023, 07:59

The used configurations are:
- https://github.com/aimeos/aimeos/blob/m ... hp#L93-L96
- https://github.com/aimeos/aimeos/blob/m ... #L137-L140

Essentially, they will use the MAIL_FROM_NAME configuration from the .env file if everything is correct.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

columbo
Advanced
Posts: 125
Joined: 09 Oct 2019, 09:42

Re: How to set mail from-name?

Post by columbo » 22 Nov 2023, 22:16

I have double checked my settings and everything seems to be fine.
in .env MAIL_FROM_NAME='My company' is set, also in mail.php

FROM-NAME is still missing in payment mail source:
Screenshot 2023-11-22 230057.png
Screenshot 2023-11-22 230057.png (8.84 KiB) Viewed 3094 times

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: How to set mail from-name?

Post by aimeos » 24 Nov 2023, 07:11

The name is handed over but it may be that the Symfony mailer component doesn't use it:
https://github.com/aimeos/ai-controller ... il.php#L98
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

columbo
Advanced
Posts: 125
Joined: 09 Oct 2019, 09:42

Re: How to set mail from-name?

Post by columbo » 26 Nov 2023, 10:18

ok - What is your suggestion to fix this?

Copying, overwriting from() (/vendor/aimeos/ai-laravel/src/Base/Mail/Message) and adding MAIL_FROM_NAME works, but do you have a better suggestion?

Code: Select all

public function from( string $email, string $name = null ) : Iface
{
	if( $email ) {
		//$this->message->from( $email );
		$this->message->from(new Address($email, env('MAIL_FROM_NAME')));
	}
	return $this;
}
thank you

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: How to set mail from-name?

Post by aimeos » 27 Nov 2023, 08:09

In that case, it's pretty easy and we've created a PR with the required changes. You can try yourself using:

Code: Select all

composer req aimeos/ai-laravel:2023.10.x-dev
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

columbo
Advanced
Posts: 125
Joined: 09 Oct 2019, 09:42

Re: How to set mail from-name?

Post by columbo » 27 Nov 2023, 21:55

great - it works perfectly
thank you

Post Reply