PDA

View Full Version : Make email address show correctly in Outlook


Mark Harris
12-15-2007, 06:01 AM
I was having the problem that outlook was showing the address that the email is from as:
user@server.domain.com; on behalf of; noreply@domain.com

in outlook, on the email pane the from address is correct, but when viewing the email it would show the above message.

To fix this, you can edit includes/class.misc.php and scroll to the very end.

There you will see the following:

/* Send email out after minor cleanups..*/
function sendmail($to, $subject, $message, $from, $headers = '') {

//TODO: provide an option to use SMTP server. Log all outgoign emails??
//do some cleanup...avoid stupid errors.
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
$message = preg_replace("/(\r\n|\r)/s", "\n", trim($message));
$headers = "From: $from \r\n" . $headers;
//echo "[$to,$subject,$message ".$headers.']';
mail($to,$subject,$message,trim($headers));
}


You can change that to

/* Send email out after minor cleanups..*/
function sendmail($to, $subject, $message, $from, $headers = '') {

//TODO: provide an option to use SMTP server. Log all outgoign emails??
//do some cleanup...avoid stupid errors.
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
$message = preg_replace("/(\r\n|\r)/s", "\n", trim($message));
$headers = "From: $from \r\n" . $headers;

$headers = "Sender: $from \r\n" . $headers;
$headers = "X-Mailer: osTicket 1.6 \r\n" . $headers;

//echo "[$to,$subject,$message ".$headers.']';
mail($to,$subject,$message,trim($headers));
}


The x-mailer header is simply for my own use, but adding the Sender: header fixes the display error.

spaycegirl
01-03-2008, 06:11 AM
Thanks Mark for the tip. I've installed this and my system works great.

4ice
01-03-2008, 09:13 AM
I was having the problem that outlook was showing the address that the email is from as:
user@server.domain.com; on behalf of; noreply@domain.com

in outlook, on the email pane the from address is correct, but when viewing the email it would show the above message.

To fix this, you can edit includes/class.misc.php and scroll to the very end.

There you will see the following:
a bunch of PHP code

You can change that to
a bunch of PHP code

The x-mailer header is simply for my own use, but adding the Sender: header fixes the display error.

Hi Mark, it seems that Peter has put your code already in his latest download. But overhere incoming messages in Outlook have no sender at all (no name and no email). But in the email itself I get:
Sender: noreply@domain.com
From: noreply@domain.com
X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on
xxx.xxx.com
X-Spam-Level:
X-Spam-Status: No, score=0.2 required=7.0 tests=NO_REAL_NAME autolearn=no
version=3.0.4
as plain text.

I'm thinking of implementing the php mailer class, it's also open source and works perfectly. Anyone else has this also?

peter
01-03-2008, 02:26 PM
4ice,
The plan is to use PEAR mail classes plus support SMTP for outgoing emails.

breakdaice
01-09-2008, 11:14 AM
IMHO by RFC these lines should be:

$headers = "From: \"$from\" <$from> \r\n" . $headers;
$headers = "Sender: \"$from\" <$from> \r\n" . $headers;


Cheers,
iCE

nasiman
01-29-2008, 10:02 PM
Tried everything above.
Then commented out the next line of code in class.misc.php

$headers = "X-Mailer: osTicket 1.6 \r\n" . $headers;

and now i can see the From and email address in the outlook. :D

4ice
01-30-2008, 08:27 AM
Tried everything above.
Then commented out the next line of code in class.misc.php

$headers = "X-Mailer: osTicket 1.6 \r\n" . $headers;

and now i can see the From and email address in the outlook. :D

Have you tried installing RC3? Because it should be fixed there already.