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

How to set smtp from e-mail? #458

Closed
Sogl opened this issue Feb 15, 2016 · 19 comments
Closed

How to set smtp from e-mail? #458

Sogl opened this issue Feb 15, 2016 · 19 comments

Comments

@Sogl
Copy link

Sogl commented Feb 15, 2016

Hi!

My notification settings:
image

I want to set From e-mail other than Reply-to e-mail.
Now I did this only with set in class.phpmailer.php, line 1199:

protected function smtpSend($header, $body)
    {
        $bad_rcpt = array();

        if (!$this->smtpConnect()) {
            throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
        }
//        $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
        $smtp_from = 'support@domain.com';
        if (!$this->smtp->mail($smtp_from)) {
            $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
            throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
        }

support@domain.com is our mailgate e-mail, admin@domain.com is administrator e-mail.

Maybe I missed this option somewhere in the web interface?

@tomolimo
Copy link
Contributor

Hello,

That’s the way to do it:

You don’t need to change source code for that!

Regards,

Olivier MORON

@Sogl
Copy link
Author

Sogl commented Feb 15, 2016

@tomolimo I can't see your attached image... something broke

@tomolimo
Copy link
Contributor

image

@Sogl
Copy link
Author

Sogl commented Feb 15, 2016

With this setting GLPI sends me recursive e-mails: 1 mail to sender/user and 1 mail to support@domain.com...support is my mailgate.

But with my code change:

  1. User send e-mail to support@domain.com
  2. 1 mail confirmation to user from support@domain.com (tickets mailgate)
  3. 1 mail confirmation to admin@domain.com (IT department)
  4. If user wants to reply - message comes to admin@domain.com (IT) because reply-to is admin@domain.com

How can I do it without code change?

@Sogl
Copy link
Author

Sogl commented Feb 15, 2016

@tomolimo Any ideas?

@tomolimo
Copy link
Contributor

Hello
As I can't reproduce the same behavior, could you please try to narrow down the problem and get basic steps to reproduce?
Thank you
Regards
Tomolimo

@Sogl
Copy link
Author

Sogl commented Feb 16, 2016

@tomolimo

Steps:

  1. Set support@domain.com mail to mailgate:
    image
  2. Set support@domain.com as administrator e-mail and admin@domain.com as reply-to email:
    image
  3. Test mail comes to support@domain.com correctly. I delete it quickly because mailgate mail.
  4. I create ticket from user@domain.com and receive 2 notifications: 1 mail notification to user@domain.com, 1 mail notification to support@domain.com:
    image

But I want admin notifications to admin@domain.com, just because support@domain.com creates new tickets every 5 minutes in loop (mailgate). user@domain.com see support@domain.com as email sender, but if he want to answer, letter comes to admin@domain.com because reply-to.

My class.phpmailer.php change let me send test mail to admin@domain.com (not mailgate by default) , I set it as Admin email and send all ticket notifications to admin@domain.com. How it looks with change:
image

Clear? =)

@tomolimo
Copy link
Contributor

Hello,

Could you clarify the point 4?

I create ticket from user@domain.com and receive 2 notifications: 1 mail notification to user@domain.com, 1 mail notification to support@domain.com

Do you mean that for each ticket creation an email is sent to support@domain.com?
If it's the case, then you may have a wrong notification 'Recipients' settings in the 'Setup' > 'Notifications' > 'Notifications' see the one that is applied for ticket creation.

@Sogl
Copy link
Author

Sogl commented Feb 18, 2016

Do you mean that for each ticket creation an email is sent to support@domain.com?

Yes.

If it's the case, then you may have a wrong notification 'Recipients' settings in the 'Setup' > 'Notifications' > 'Notifications' see the one that is applied for ticket creation.

You mean New Ticket notification recipients?
image

Where I can find this list to edit e-mails? Also I can't find Admin reply-to option.

@tomolimo
Copy link
Contributor

Hello
In the screen capture you sent, there is the answer to your problem: delete the first recipient named 'Administrator'.
Regards
Tomolimo

@Sogl
Copy link
Author

Sogl commented Feb 18, 2016

I can't send emails: 550 5.7.1 Client does not have permissions to send as this sender More info:
https://support.desk.com/customer/portal/articles/1104707-client-does-not-have-permissions-to-send-as-this-sender-error

My admin@domain.com is alias on Exchange. I can't give my support@domain.com rights to the aliases (this is not possible).

@Sogl
Copy link
Author

Sogl commented Feb 18, 2016

In the screen capture you sent, there is the answer to your problem: delete the first recipient named 'Administrator'.

After deleting Administrator new tickets notifications sends only to user@domain.com, but I need IT department admin@domain.com too.

@tomolimo
Copy link
Contributor

I don't understand this

I can't send emails: 550 5.7.1 Client does not have permissions to send as this sender More info:
https://support.desk.com/customer/portal/articles/1104707-client-does-not-have-permissions-to-send-as-this-sender-error

My admin@domain.com is alias on Exchange. I can't give my support@domain.com rights to the aliases (this is not possible).

But regarding this I understand the need

After deleting Administrator new tickets notifications sends only to user@domain.com, but I need IT department admin@domain.com too.

IT department is NOT Administrator: you must define another user/group with another email (<> support@domain.com) for that. And you may set the new group in the 'new ticket' recipient list.

@Sogl
Copy link
Author

Sogl commented Feb 19, 2016

Finally I solved my problem in this way:

  1. Set organization email to support@domain.com (Administration -> Entities).
    After that change all new tickets sender in MySQL table glpi_queuedmails (column sender) becomes support@domain.com. It was admin@domain.com earlier. If fix permissions problem.
    More info:
    http://forum.glpi-project.org/viewtopic.php?pid=164227#p164227
  2. Set admin and replyto mails to admin@domain.com in Notifications:
    image

That's all! User creates ticket and notifications sends to admin and user.

Small problems remain:

  1. I don't know why, but after deleting Administrator and adding IT group in New Ticket recipitents, emails sending stop to Requester. No Requester row in glpi_queuedmails. Screen:
    image
    Maybe it's because requester email equals one of IT-department's mails? (I used my email for tests)
  2. class.phpmailer.php can't connect to Exchange server with default 272 line:
public $AuthType = '';

Output:

2016-02-19 04:42:33     SERVER -> CLIENT: 220 exchange.domain.com Microsoft ESMTP MAIL Service ready at Fri, 19 Feb 2016 14:                                                                                                              42:32 +1000
2016-02-19 04:42:33     CLIENT -> SERVER: EHLO inventory.domain.com
2016-02-19 04:42:33     SERVER -> CLIENT: 250-exchange.domain.com Hello [192.168.1.240]
250-SIZE 20971520
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-X-ANONYMOUSTLS
250-AUTH GSSAPI NTLM
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250-XRDST
250 XSHADOW
2016-02-19 04:42:33     CLIENT -> SERVER: STARTTLS
2016-02-19 04:42:33     SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2016-02-19 04:42:33     CLIENT -> SERVER: EHLO inventory.domain.com
2016-02-19 04:42:33     SERVER -> CLIENT: 250-exchange.domain.com Hello [192.168.1.240]
250-SIZE 20971520
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH GSSAPI NTLM LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250-XRDST
250 XSHADOW
2016-02-19 04:42:33     CLIENT -> SERVER: AUTH PLAIN
2016-02-19 04:42:38     SERVER -> CLIENT: 504 5.7.4 Unrecognized authentication type
2016-02-19 04:42:38     SMTP ERROR: AUTH command failed: 504 5.7.4 Unrecognized authentication type
2016-02-19 04:42:38     CLIENT -> SERVER: QUIT
2016-02-19 04:42:38     SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
SMTP connect() failed.
2016-02-19 04:42:38     SERVER -> CLIENT: 220 exchange.domain.com Microsoft ESMTP MAIL Service ready at Fri, 19 Feb 2016 14:                                                                                                              42:37 +1000
2016-02-19 04:42:38     CLIENT -> SERVER: EHLO inventory.domain.com
2016-02-19 04:42:38     SERVER -> CLIENT: 250-exchange.domain.com Hello [192.168.1.240]
250-SIZE 20971520
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-X-ANONYMOUSTLS
250-AUTH GSSAPI NTLM
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250-XRDST
250 XSHADOW
2016-02-19 04:42:38     CLIENT -> SERVER: STARTTLS
2016-02-19 04:42:38     SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2016-02-19 04:42:38     CLIENT -> SERVER: EHLO inventory.domain.com
2016-02-19 04:42:38     SERVER -> CLIENT: 250-exchange.domain.com Hello [192.168.1.240]
250-SIZE 20971520
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH GSSAPI NTLM LOGIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250-XRDST
250 XSHADOW
2016-02-19 04:42:38     CLIENT -> SERVER: AUTH PLAIN
2016-02-19 04:42:43     SERVER -> CLIENT: 504 5.7.4 Unrecognized authentication type
2016-02-19 04:42:43     SMTP ERROR: AUTH command failed: 504 5.7.4 Unrecognized authentication type
2016-02-19 04:42:43     CLIENT -> SERVER: QUIT
2016-02-19 04:42:43     SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
SMTP connect() failed.

And no errors in GLPI logs at all! Only with public $SMTPDebug = 2; I saw errors in console.

So... after this change:

public $AuthType = 'LOGIN';

All my mails works fine. Where I can find auth type in GLPI web-interface?

My SMTP settings:
image

IT department is NOT Administrator: you must define another user/group with another email

It doesn't matter in our company because only IT deapartment uses GLPI.

@tomolimo
Copy link
Contributor

Hello,

Maybe it's because requester email equals one of IT-department's mails? (I used my email for tests)

What is your setting for
image?

Exchange doesn't support TLS, but only BASIC

@Sogl
Copy link
Author

Sogl commented Feb 20, 2016

What is your setting for ... ?

Enabled.

Exchange doesn't support TLS, but only BASIC

TLS is encryption type/protocol. BASIC is auth type. This is different things.

From class.phpmailer.php comment:

/**
     * SMTP auth type.
     * Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
     * @type string
     */
    public $AuthType = '';

But on default LOGIN is not used, error.

@tomolimo
Copy link
Contributor

Hello,

You are right about TLS and BASIC, but you should look at this in the traces:

2016-02-19 04:42:33 CLIENT -> SERVER: AUTH PLAIN
2016-02-19 04:42:38 SERVER -> CLIENT: 504 5.7.4 Unrecognized authentication type
2016-02-19 04:42:38 SMTP ERROR: AUTH command failed: 504 5.7.4 Unrecognized authentication type

So do some googling to find how to configure the connection.

@Sogl
Copy link
Author

Sogl commented Feb 24, 2016

You are right about TLS and BASIC, but you should look at this in the traces:

If I leave it empty by default, my connection uses PLAIN. But I need LOGIN.
Where I can set it in GLPI?

@trasher
Copy link
Contributor

trasher commented Jul 5, 2017

Set "Way of sending email" to "SMTP", and not "SMTP+TLS".

Closing; this is more a user support than a bug; and that seems solved anyways.

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

3 participants