I'm attempting to send an email using php's mail() function with
a Gmail "Announcement-only" group and a "Reply-To" header. I have all
of that setup correctly, but the reply to address appends the servers
FQDN to the address (ie recipi...@domain.com@server.ispdomain.com).
I've figured out that it deals with a sender envelope issue, so for
the 5th parameter I've passed "-f re...@domain.com -r
re...@domain.com". The 're...@domain.com' is the address that I would
like to have users reply to. Am I missing something?
Also, I'm using an "Announcement-only" group and a "Reply-To"
header because I don't want peoples replies to announcements to go to
the whole group, but rather an defined group of people. Is there an
easier way to handle this than what I'm currently doing?
Thanks,
Dave
I haven't tried it.....
From http://www.hscripts.com/tutorials/php/sendMail.php
Follow the steps to do it yourself
Step 1:
Its realy simple to send mail using php.
First define the parameters to,suject,message and header containing
from and reply address
<?php
$to = "toad...@mailservername.com";
$subject = "Just a test mail";
$message = "Just training on php";
$from = "froma...@mailservername.com";
//Header is the portinn where we will set the from address, reply to
address, cc address, etc....
//The display of address we see on the top (from,to,replyto) portion
of the composer will be based on the header we set
/* To send HTML mail, you can set the Content-type header. */
$headers1 = "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers1 .= "To: ".$to."\r\n";
$headers1 .= "From: ".$from."\r\n";
$headers1 .= "Reply-To: ".$from."\r\n";
?>
Step 2:
Now we send the mail using php api
<?php
mail($to, $subject, $message, $headers);
?>
Thanks for the reply. I actually already have a script (portions
shown below). I am able to send mail, I'm just having a problem with
the "Reply-To" header. I keep getting the servers FQDN appended to
the end of the email address. So, for example, lets say that I want
the Reply-To to be r...@domain.com, when the email gets sent it will
read "r...@domain.com@server.hostdomain.com". I need to remove the
trailing domain name. I have read that it will require an adjustment
to the sender envelope. Maybe you can see what I'm doing wrong.
Dave
function send() {
$mime = "";
if ($this->from == 'user...@domain.org') {
# if ($this->from == 're...@domain.org') {
# $mime .= "From: reply\@domain.org\r\n";
# $mime .= "From: username\@domain.org\r\n";
$mime .= "From: ".$this->from. "\n";
$mime .= "Reply-To: reply\@domain.org\n";
} else if (! empty($this->from)) { $mime .= "From: ".$this->from.
"\n"; }
if (! empty($this->cc)) { $mime .= "Cc: ".$this->cc. "\n"; }
if (! empty($this->bcc)) { $mime .= "Bcc: ".$this->bcc. "\n"; }
if (! empty($this->headers)) { $mime .= $this->headers. "\n"; }
if (! empty($this->body)) { $this->add_attachment($this->body,
"", "text/html"); }
$mime .= "MIME-Version: 1.0\n".$this->build_multipart();
return( mail($this->to, $this->subject, "", $mime, '-f domain.org -
r domain.org') );
# return( mail($this->to, $this->subject, "", $mime, '-f
re...@domain.org -r re...@domain.org') );
}
PS.
The commented out sections are other attempts at getting it work
correctly. Also, the values are assigned in other functions.