Skip to content
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

Swift Mailer via PHP CLI not sending hostname for e-mail #3216

Closed
jkapi opened this issue Mar 23, 2021 · 1 comment
Closed

Swift Mailer via PHP CLI not sending hostname for e-mail #3216

jkapi opened this issue Mar 23, 2021 · 1 comment

Comments

@jkapi
Copy link

jkapi commented Mar 23, 2021

Background (please complete the following information):

  • Panel or Daemon: Panel
  • Version of Panel/Daemon: 1.3.1
  • Server's OS: CentOS 8
  • Your Computer's OS & Browser: N/A but Fedora 33 + Firefox 86

Describe the bug
A clear and concise description of what the bug is.
Please provide additional information too, depending on what you have issues with:
Panel: php -v (the php version in use). v7.4.16
Daemon: uname -a and docker info (your kernel version and information regarding docker)

I'm using Gmail to send out emails for Pterodactyl panel. I'm doing this via smtp-relay.gmail.com and testing via /admin/settings/mail works. When I create new accounts it doesn't send an e-mail to the recipients. Because I was worried that it could be a problem of them not receiving mail from my domain I also tried sending a password reset to myself but it did again not get to my inbox.

By digging a little further in the logs I got the following error: https://ptero.co/asexitufet.shell
I've searched for the error online and found that Google mail requires a sender hostname to be sent with the mail and php cli doesn't set $_SERVER["SERVER_NAME"] so it fails.

To Reproduce
Steps to reproduce the behavior:

  1. Install panel as per usual
  2. Go to mail settings
  3. Set the SMTP host to smtp-relay.gmail.com and set the required login.
  4. Test via website and observe it working
  5. Do something to send a mail via the queue worker like a password reset or account activation and see it not working

Expected behavior
The expected behavoir is that the queue worker just sends the mail out.

Hacky temporary fix
While searching on the internet for this problem I saw that this is a known problem in Laravel Swift. A way to fix it is to add the line
$_SERVER["SERVER_NAME"] = "pterodactyl.domain.example"; //or gethostname()
(where pterodactyl.domain.example is your server name ofcourse)
to app/Providers/AppServiceProvider.php in the boot function. This sets your SERVER_NAME and thus Swift has a SERVER_NAME to send with the mail and Gmail SMTP accepts and sends the mail.

TL;DR
PHP CLI doesn't set $_SERVER["SERVER_NAME"] which causes sending mails with Gmail to fail via the Queue Workers.

@jkapi jkapi closed this as completed Mar 23, 2021
@jkapi
Copy link
Author

jkapi commented Mar 23, 2021

Seems that there's already a pull request for this #3110

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

No branches or pull requests

1 participant