Skip to content

Support reply-to header #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2022
Merged

Support reply-to header #9

merged 2 commits into from
Jul 28, 2022

Conversation

scardinius
Copy link
Contributor

PHP API Client should support replyTo parameter as API Freshmail has.

@@ -302,6 +333,18 @@ function jsonSerialize(): array
'recipients' => $recipients
];

$replyTo = [];
if ($this->getReplyToEmail()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is one mistake, if replyTo email address is not set then code failed with message:

PHP Fatal error:  Uncaught Error: Call to a member function getEmail() on null in /Users/suchy/project/php-api-client-calthaeu/src/Messaging/Mail/MailBag.php:187

because we always want to retrieve property by method on object that was not initialize:

public function getReplyToEmail(): string
    {
        return $this->replyTo->getEmail();
    }

To fix code should look like this:

/**
     * @return string
     */
    public function getReplyToEmail(): ?string
    {
        if ($this->replyTo) {
            return $this->replyTo->getEmail();
        }

        return null;
    }

    /**
     * @return string
     */
    public function getReplyToName(): ?string
    {
        if ($this->replyTo) {
            return $this->replyTo->getName();
        }

        return null;
    }

and then it works perfectly

Copy link
Contributor Author

@scardinius scardinius Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, indeed. Fixed. Thank you!

@ankalagon ankalagon merged commit 0bb40aa into FreshMail:master Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants