Jump to content

Changing The Sendmail Return-Path?


Sluggo

Recommended Posts

I have a number of Perl/CGI scripts that use my web host's Sendmail on a UNIX platform for the form e-mail processing. All works as it should, but I would like to change what is inserted into the e-mail header for the [Return-Path]. Currently Sendmail uses this formatting: my_user_name@local_host for the Return-Path, with local_host being my web host's server name that I'm assigned to. For normal execution of the e-mail with a valid e-mail address, there's no problem, but if the e-mail bounces for any reason, it's NOT returned to the address in the From: line which is mine. Instead it's stored on my web host's server and I have to use PINE through SSH to access it. This setup does work, but I do not know if and when any e-mails bounce unless I check PINE on a regular basis. Now if I can get the Return-Path to be my From: address, I would get the bounces directly in my regular Inbox that I access through POP3. The above configuration would be desirable for large mailing lists so that the Inbox of the From: address (if valid) would not get flooded with the bounces, or for someone sending into a mailing list, but that is not my situation. I found the following in the Sendmail FAQ here

Q3.15 -- Why does the Unix From line get mysteriously munged when I send to an alias?Date: December 3, 1997 ``It's not a bug, it's a feature.'' This happens when you have an owner-list alias and you send to list. V8 propagates the owner information into the SMTP envelope sender field (which appears as the Unix From line [sometimes incorrectly referred to as the From-space "header"] on Unix mail or as the Return-Path: header) so that downstream errors are properly returned to the mailing list owner instead of to the sender. In order to make this appear as sensible as possible to end users, I recommend making the owner point to a "request" address -- for example: list:  :include:/path/name/list.list owner-list: list-request list-request: eric This will make message sent to list come out as being "From list-request" instead of "From eric".
I've tried using this in my scripts:
print MAIL "Return-Path: $administrator\n";

but that does nothing. My web host says that where they do not support user installed scripts (which I can understand), that they can't offer me any assistance even though I'm using their supplied Sendmail. I've searched through the Sendmail forum (and many other forums), and the only postings that more or less ask the same as what I'm asking, say that some of the Sendmail configuration files have to be changed or modified. Naturally, that is not possible where it would have to be my web host that would have to make the changes, and there's no way that they (or any other web host) would be willing to do that for just one user. Any suggestions?

Link to comment
Share on other sites

Ragnar Paulson
I have a number of Perl/CGI scripts that use my web host's Sendmail on a UNIX platform for the form e-mail processing. All works as it should, but I would like to change what is inserted  into the e-mail header for the [Return-Path]. Currently Sendmail uses this formatting: my_user_name@local_host for the Return-Path, with local_host being my web host's server name that I'm assigned to. For normal execution of the e-mail with a valid e-mail address, there's no problem, but if the e-mail bounces for any reason, it's NOT returned to the address in the From: line which is mine. Instead it's stored on my web host's server and I have to use PINE through SSH to access it. This setup does work, but I do not know if and when any e-mails bounce unless I check PINE on a regular basis. Now if I can get the Return-Path to be my From: address, I would get the bounces directly in my regular Inbox that I access through POP3. The above configuration would be desirable for large mailing lists so that the Inbox of the From: address (if valid) would not get flooded with the bounces, or for someone sending into a mailing list, but that is not my situation. I found the following in the Sendmail FAQ hereI've tried using this in my scripts:
print MAIL "Return-Path: $administrator\n";

but that does nothing. My web host says that where they do not support user installed scripts (which I can understand), that they can't offer me any assistance even though I'm using their supplied Sendmail. I've searched through the Sendmail forum (and many other forums), and the only postings that more or less ask the same as what I'm asking, say that some of the Sendmail configuration files have to be changed or modified. Naturally, that is not possible where it would have to be my web host that would have to make the changes, and there's no way that they (or any other web host) would be willing to do that for just one user. Any suggestions?

There is a switch on sendmail that allows you to change the from line (aka Return-Path:) but you need to be root to use it and it's not recommended.Why not try adding a "Reply-To:" header? Any RFC822 compliant mailer should honor the Reply-To line before the "from" line. Ragnar
Link to comment
Share on other sites

There is a switch on sendmail that allows you to change the from line (aka Return-Path:) but you need to be root to use it and it's not recommended.Why not try adding a "Reply-To:" header?  Any RFC822 compliant mailer should honor the Reply-To line before the "from" line.  Ragnar

Right, I think that I've seen the switch that you refer to, but as you (and I) said, that has to be done by my web host, and that ain't gonna happen just for little ole me :(I have been using the Reply-To: for all of my scripts right along. That does work as it should for any replies that I want to respond to for my copies of mail that I do receive from my scripts, but does nothing for the Return-Path if the form's confirmation e-mail is sent to a non-valid address.This is what the RFC822 spec states for the Return-Path:
    4.3.1.  RETURN-PATH        This field  is  added  by  the  final  transport  system  that        delivers  the message to its recipient.  The field is intended        to contain definitive information about the address and  route        back to the message's originator.        Note:  The "Reply-To" field is added  by  the  originator  and              serves  to  direct  replies,  whereas the "Return-Path"              field is used to identify a path back to  the  origina-              tor.        While the syntax  indicates  that  a  route  specification  is        optional,  every attempt should be made to provide that infor-        mation in this field.
Even if there was a module that would configure the header as I wanted it, the mail would still have to go through my web host's Sendmail afterwards, so I guess that short of my installing my own Sendmail, I won't be able to change the Return-Path to what I want.Am I wrong?
Link to comment
Share on other sites

Ragnar Paulson

Sorry, I didn't think through the original question. I understand the issue now and I don't think you can get sendmail (when later acting as the MTA) to generatenotices back to your Reply-To: or From: lines. As I see it you have two options. On your sendmail invocation you could use "-N never". This would mean you would never be notified of failures. If you want to be notified of failures though then your only option may be to forward the notifications or pop them off as well. How is it you have SSH access to the webhosting account but not POP? Anyway with SSH access can you not create a .procmailrc in the home directory and forward all e-mail to your other pop account?Ragnar

Link to comment
Share on other sites

Thank you Ragnar for your time.

As I see it you have two options. On your sendmail invocation you could use "-N never". This would mean you would never be notified of failures.
That I would not want.
If you want to be notified of failures though then your only option may be to forward the notifications or pop them off as well.
I do get a copy (actually a separate e-mail) of the e-mails through my POP3 accounts. It's just the failures that I'm concerned about.
How is it you have SSH access to the webhosting account but not POP?
I do have POP3 access for all of my domain e-mail accounts. It's just that the failures for the form submitted e-mails are sent back to (my_user_name@my_domain) which I then have to use PINE through SSH to access them, or to just check to see if there are any there. That's the part, or steps that I want to eliminate, and just have any failures sent to my regular address.
Anyway with SSH access can you not create a .procmailrc in the home directory and forward all e-mail to your other pop account?
I'm not familiar with a .procmailrc, can you give me a brief description of it, and how it could be used for what I want? This is the code that I'm using in my Perl scripts for Sendmail
  # Send E-Mail for confirmation  if ($mail == 1 && $email2) {    open  MAIL, "|$mailprog $email2" || die "Can't open $mailprog!\n";    print MAIL "From: $administrator\n";    print MAIL "To: $email2\n";    print MAIL "Subject: Confirmation Notice\n";    print MAIL "Reply-To: $administrator\n";    print MAIL "$body\n";    close MAIL;  }

Is there any way that I can use any switch in there for what I want? Thank you.

Link to comment
Share on other sites

Ragnar Paulson
I do get a copy (actually a separate e-mail) of the e-mails through my POP3 accounts. It's just the failures that I'm concerned about.I do have POP3 access for all of my domain e-mail accounts. It's just that the failures for the form submitted e-mails are sent back to (my_user_name@my_domain) which I then have to use PINE through SSH to access them, or to just check to see if there are any there.
Without actually logging in to your web server, or having root access to it, I can only make half-assed guesses. B) As you have a shell access and a mailbox on the web server, the only thing stopping you from popping the mail off would be if the admin deliberately blocked or disabled pop access. So the first and easiest thing to try is add another account to your mail client, use the webservers ip addrsess as server name (not your usually mail server) and the same account/password you use for SSH.
That's the part, or steps that I want to eliminate, and just have any failures sent to my regular address.I'm not familiar with a .procmailrc, can you give me a brief description of it, and how it could be used for what I want?
Again it depends on how the web server is set up. The default for sendmail is to allow procmailrc processing. The default for SSH is to log you into your home directory. The sysadmin could disable the first and put you in the chroot jail for the second. Both of which would be prudent for security reasons, on the other hand I wouldn't even allow you ssh access to my web server, for security reasons. :)So assuming both sendmail and ssh are default, when you first login with ssh you are in your home directory and can create a .procmailrc file that has the following lines in it::0:*!^X-Loop: my_user_name@my_domain| formail -A"my_user_name@my_domain" | $SENDMAIL -oi your_user@yourmail.domain
This is the code that I'm using in my Perl scripts for Sendmail
  # Send E-Mail for confirmation  if ($mail == 1 && $email2) {    open  MAIL, "|$mailprog $email2" || die "Can't open $mailprog!\n";    print MAIL "From: $administrator\n";    print MAIL "To: $email2\n";    print MAIL "Subject: Confirmation Notice\n";    print MAIL "Reply-To: $administrator\n";    print MAIL "$body\n";    close MAIL;  }

Is there any way that I can use any switch in there for what I want? Thank you.

That's a scary piece of code. :) I hope you have sufficient pre-processing in placethat prevents your .cgi from being used as a spam generator? Be wary if either of $email2 or $body can be entered as input from the cgi user.Good luck. I'm about out of ideas. Cheers,Ragnar
Link to comment
Share on other sites

Sorry for the delay in getting back here.Thank you, I'll look into using .procmailrc, that sounds exactly like what I would need.

I hope you have sufficient pre-processing in place that prevents your .cgi from being used as a spam generator?
I do have a referrer check in the scripts so that any remote execution attempts will not execute them.Thank you again for your time.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...