We have our business mail in a provider where the usernames configuration are a bit different. Instead of using the "@" character as the separator, they use the character "=".
Is it possible to see the tutorial or provider:
https://www.hostnet.com.br/config.email/[email protected]&tutorial=11
I'm sending a printscreen of my configuration:
In Setup -> Notification -> Email followups configuration.

I've done some tests and I've discovered how to fix it for this cases.
Is necessary to inform 2 more parameters ($this->Sender and $this->From) for phpmailer in the file "/var/www/glpi/inc/glpimailer.class.php" after line 69.
Before:
if ($CFG_GLPI['smtp_username'] != '') {
$this->SMTPAuth = true;
$this->Username = $CFG_GLPI['smtp_username'];
$this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
}
After:
if ($CFG_GLPI['smtp_username'] != '') {
$this->SMTPAuth = true;
$this->Username = $CFG_GLPI['smtp_username'];
$this->Password = Toolbox::decrypt($CFG_GLPI['smtp_passwd'], GLPIKEY);
$this->Sender = str_replace('=','@',$CFG_GLPI['smtp_username']);
$this->From = str_replace('=','@',$CFG_GLPI['smtp_username']);
}
I would like to suggest, if I have enabled the debug mode in GLPI, would be interesting have an option to enable debug of phpmailer and improve the way to collect mail logs for discover possible errors.
$this->SMTPDebug = 1; // 1 = errors and messages or 2 = messages only
Best Regards
Wanderlei H眉ttel
Hello,
I do not really understand what goes wrong with your configuration.
I think using smtp username as "from" in the resulting email is a mistake. The "from" should be populated using the "Administrator email" from the preferences. And what about real email address with a "=" sign? (seems to be legible).
Also, +1 to set debug on phpmailer when glpi is in debug mode.
Hello Johan
Yes about "from" you are right, but I guess PHPMailer needs this information to send the email correct when the username is not an email. In my case (and I guess can have many others) my username is not a email valid, the separator character of username and domain is "=" and not "@". I also know that exists some providers that the username from authentication is only a single username without domain suffix.
The error from PHPMailer by default without any modification in "/var/www/glpi/inc/glpimailer.class.php". evelin@mydomain is the user I've opened a new ticket.
2017-03-24 11:06:22 CLIENT -> SERVER: EHLO 192.168.1.1
2017-03-24 11:06:22 CLIENT -> SERVER: STARTTLS
2017-03-24 11:06:22 CLIENT -> SERVER: EHLO 192.168.1.1
2017-03-24 11:06:22 CLIENT -> SERVER: AUTH LOGIN
2017-03-24 11:06:22 CLIENT -> SERVER: Y2hhbWFkb3M9ZmFtYWNyaXMuY29tLmJy
2017-03-24 11:06:23 CLIENT -> SERVER: ZzBBazJLTmlka0F0N1BnNnZlN3ZiNExu
2017-03-24 11:06:23 CLIENT -> SERVER: MAIL FROM:
2017-03-24 11:06:23 CLIENT -> SERVER: RCPT TO:
2017-03-24 11:06:23 SMTP ERROR: RCPT TO command failed: 553 5.7.1 : Sender address rejected: not owned by user chamados=mydomain.com.br
2017-03-24 11:06:23 CLIENT -> SERVER: QUIT
2017-03-24 11:06:23 SMTP Error: The following recipients failed: [email protected]: : Sender address rejected: not owned by user chamados=mydomain.com.br
2017-03-24 11:06:23 CLIENT -> SERVER: EHLO 192.168.1.1
2017-03-24 11:06:23 CLIENT -> SERVER: STARTTLS
2017-03-24 11:06:23 CLIENT -> SERVER: EHLO 192.168.1.1
2017-03-24 11:06:23 CLIENT -> SERVER: AUTH LOGIN
2017-03-24 11:06:23 CLIENT -> SERVER: Y2hhbWFkb3M9ZmFtYWNyaXMuY29tLmJy
2017-03-24 11:06:23 CLIENT -> SERVER: ZzBBazJLTmlka0F0N1BnNnZlN3ZiNExu
2017-03-24 11:06:23 CLIENT -> SERVER: MAIL FROM:
2017-03-24 11:06:23 CLIENT -> SERVER: RCPT TO:
2017-03-24 11:06:23 SMTP ERROR: RCPT TO command failed: 553 5.7.1 : Sender address rejected: not owned by user chamados=mydomain.com.br
2017-03-24 11:06:23 CLIENT -> SERVER: QUIT
2017-03-24 11:06:23 SMTP Error: The following recipients failed: [email protected]: : Sender address rejected: not owned by user chamados=mydomain.com.br
If I add the parameter "$this->Sender" in "/var/www/glpi/inc/glpimailer.class.php" the notification works as expected but if you print the variabel "$this" is possible to see a wrong "email" in "[From]"
GLPIMailer Object
(
[Version] => 5.2.16
[Priority] =>
[CharSet] => utf-8
[ContentType] => text/plain
[Encoding] => 8bit
[ErrorInfo] =>
[From] => root@localhost
[FromName] => Root User
[Sender] => [email protected]
[ReturnPath] =>
[Subject] =>
[Body] =>
[AltBody] =>
[Ical] =>
[MIMEBody:protected] =>
[MIMEHeader:protected] =>
[mailHeader:protected] =>
[WordWrap] => 80
[Mailer] => smtp
[Sendmail] => /usr/sbin/sendmail
[UseSendmailOptions] => 1
[PluginDir] =>
[ConfirmReadingTo] =>
[Hostname] =>
[MessageID] =>
[MessageDate] =>
[Host] => smtp.mydomain.com.br:587
[Port] => 25
[Helo] =>
[SMTPSecure] =>
[SMTPAutoTLS] => 1
[SMTPAuth] => 1
[SMTPOptions] => Array
...
As you can see, I've included the option "$this->Sender" in "/var/www/glpi/inc/glpimailer.class.php" the notification works as expected.

Or another way should be create a new field to inform the email of account if the username is something like "username=domain.com.br" or just "username" and include the option $this->Sender in in "/var/www/glpi/inc/glpimailer.class.php"
If you want I could send you a username an password for test purpose (but in private)
Best regards
Wanderlei H眉ttel
According to the error message:
Sender address rejected: not owned by user chamados=mydomain.com.br
The issue is you use a SMTP username that is not correct with the configured sender... As far as I understand, this is a limitation on your SMTP side.
I guess that is you set the "Administrator email" to the correct value (chamados@) it also solve the issue, right?
As far as I can see, we do not use any "sender" in our email configuration, I'll check phpmailer docs to know what it is about exactly; I guess this is only this part that you need in your case (we do not have to change the from prgramatically).
Hello
If I change my Administrator email to called @ mydomain it works.
But it is strange to receive notifications in the same mailbox that the users send the mails to open new tickets.
I understand that it is a particulary case of my domain, but how the purpose of GLPI is for attend companies, many mail business servers has its own particularity and more restrictions about send emails from another address. Probably because can characterize as SPAM.
When some admins fail to configure the notification they usually use mail servers like gmail, yahoo as alternative and they give up to configure the email of they own domain because the errors.
I 'll stay waiting!
Best Regards
Wanderlei H眉ttel
If I change my Administrator email to called @ mydomain it works.
OK, thank you for the confirmation :)
I understand that it is a particulary case of my domain,
Yes it is, at least for now... But I'm not saying "no" to your request; I'm just trying to understand the implications ;)
I took a look into the code, it seems that phpmailer do copy the "from" to the "sender" per default; and in your case; this does not work. I guess that adding a "sender" configuration for special cases like that may be the better way to go, as the automatic replacement does not seem good to me.
Any other thoughts?
I agree with you!
It would be better add a "sender" configuration for this special cases in the GLPI form and in the "/var/www/glpi/inc/glpimailer.class.php" I guess.
And about debug phpmailer I've took a look and discovered a parameter to redirect output from debug.
/**
* How to handle debug output.
* Options:
* * `echo` Output plain-text as-is, appropriate for CLI
* * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
* * `error_log` Output to error log as configured in php.ini
*
* Alternatively, you can provide a callable expecting two params: a message string and the debug level:
* <code>
* $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
* </code>
* @var string|callable
* @see SMTP::$Debugoutput
*/
public $Debugoutput = 'echo';
https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php
I guess should not difficult to implement this in GLPI
Best Regards
Wanderlei H眉ttel
That will be usefull; thank you :)
Hello @trasher . I was taking a look the the file "inc/notificationtarget.class.php" and I discovered the function "getSender" and I have some suggestions:
By default an email account must send an email using the same address used for authentication on the mail provider in the field "From", but in GLPI is a bit different, because GLPI uses the same address in the fields "From" and "To" that are from the main administrator or entity administrator.(Still there are some providers like my case that do not use a valid email as username mail address or use a single username without domain for authenticate)
I would like to suggest to create a field in "Setup -> Notifications -> Email Followups Configuration" to set the email used to send email ("From"). I guess could be the same field that we already talked above (about "sender" configuration for special cases, ou something like that).
And probably in "Administration -> Entities -> Notifications" too.
Why this?
Today:
If I only configure notifications in "Setup -> Notifications -> Email Followups Configuration", and have a different login of SMTP and Administrator mail, the mail come with the fields "From" and "To" with the Administrator email, and not with the email configured in SMTP Login in field "From". The same happens if I have the administrator mail configured in Entities.
If the field "Sender Special Case" exists, could be configured a single mail account for send the email.
This would be interesting for receive/send all mails by a default email like, [email protected] or [email protected] and notifying the administrator of GLPI using the administrator email (like [email protected], [email protected], etc)
I don't know if I was clear, but is that I would like to suggest.
If you have some doubt I'm here
Best regards
Wanderlei H眉tel
Hello @wanderleihuttel
I've begin to add some new config fields on the mail config form (only form has changed right now).
You can take a look at https://github.com/trasher/glpi/commit/773ef3fa245bd27e6b6705a2856522c1a15ab82e and tell me if that sounds OK to you.
Hello @trasher
Can you include a print screen for have a better preview?
Sure! Here it is:

Few precisions:
@trasher
Taking a look in the preview, it looks great.
Now, just wait until the release =)
I'll have to finish first; this is just the display part; nothing is done yet ;)
Hello @trasher !
I would like to thank you for the great work that you are doing in GLPI.
I've made some tests with the new email fields and now it look is working fine.
The only problem it looks the "Send a test email to the administrator", that only sent emails with "From" administrator, even if the fields "From email" and "From name" are configured.
I would like to suggest you a patch to check if the fields "from_email" and "from_email_name" exists and is not empty and use them to sent the email.
````
--- a/inc/notificationmailing.class.php 2017-09-25 12:32:15.000000000 -0300
+++ b/inc/notificationmailing.class.php 2017-09-27 16:22:31.652694624 -0300
@@ -88,7 +88,18 @@
$mmail->AddCustomHeader("Auto-Submitted: auto-generated");
// For exchange
$mmail->AddCustomHeader("X-Auto-Response-Suppress: OOF, DR, NDR, RN, NRN");
- $mmail->SetFrom($CFG_GLPI["admin_email"], $CFG_GLPI["admin_email_name"], false);
+ if(isset($CFG_GLPI["from_email"]) && $CFG_GLPI["from_email"]){
+ $from_email = $CFG_GLPI["from_email"];
+ if(isset($CFG_GLPI["from_email_name"]) && $CFG_GLPI["from_email_name"]){
+ $from_name = $CFG_GLPI["from_email_name"];
+ } else {
+ $from_name = $CFG_GLPI["admin_email_name"];
+ }
+ }else {
+ $from_email = $CFG_GLPI["admin_email"];
+ $from_name = $CFG_GLPI["admin_email_name"];
+ }
+ $mmail->SetFrom($from_email, $from_name, false);
$text = __('This is a test email.')."\n-- \n".$CFG_GLPI["mailing_signature"];
$recipient = $CFG_GLPI['admin_email'];
@@ -96,7 +107,7 @@
//force recipient to configured email address
$recipient = GLPI_FORCE_MAIL;
//add original email addess to message body
- $text .= "\n" . sprintf(__('Orignal email address was %1$s'), $CFG_GLPI['admin_email']);
+ $text .= "\n" . sprintf(__('Original email address was %1$s'), $CFG_GLPI['admin_email']);
}
$mmail->AddAddress($recipient, $CFG_GLPI["admin_email_name"]);
````
Best regards
Wanderlei
Most helpful comment
Hello @trasher !
I would like to thank you for the great work that you are doing in GLPI.
I've made some tests with the new email fields and now it look is working fine.
The only problem it looks the "Send a test email to the administrator", that only sent emails with "From" administrator, even if the fields "From email" and "From name" are configured.
I would like to suggest you a patch to check if the fields "from_email" and "from_email_name" exists and is not empty and use them to sent the email.
````
--- a/inc/notificationmailing.class.php 2017-09-25 12:32:15.000000000 -0300
+++ b/inc/notificationmailing.class.php 2017-09-27 16:22:31.652694624 -0300
@@ -88,7 +88,18 @@
$mmail->AddCustomHeader("Auto-Submitted: auto-generated");
// For exchange
$mmail->AddCustomHeader("X-Auto-Response-Suppress: OOF, DR, NDR, RN, NRN");
- $mmail->SetFrom($CFG_GLPI["admin_email"], $CFG_GLPI["admin_email_name"], false);
+ if(isset($CFG_GLPI["from_email"]) && $CFG_GLPI["from_email"]){
+ $from_email = $CFG_GLPI["from_email"];
+ if(isset($CFG_GLPI["from_email_name"]) && $CFG_GLPI["from_email_name"]){
+ $from_name = $CFG_GLPI["from_email_name"];
+ } else {
+ $from_name = $CFG_GLPI["admin_email_name"];
+ }
+ }else {
+ $from_email = $CFG_GLPI["admin_email"];
+ $from_name = $CFG_GLPI["admin_email_name"];
+ }
+ $mmail->SetFrom($from_email, $from_name, false);
@@ -96,7 +107,7 @@
//force recipient to configured email address
$recipient = GLPI_FORCE_MAIL;
//add original email addess to message body
- $text .= "\n" . sprintf(__('Orignal email address was %1$s'), $CFG_GLPI['admin_email']);
+ $text .= "\n" . sprintf(__('Original email address was %1$s'), $CFG_GLPI['admin_email']);
}
````
Best regards
Wanderlei