Domain Manage

Email Forwarding / Cpanel

Discussion in 'General Board' started by lee, Feb 26, 2015.

Thread Status:
Not open for further replies.
  1. lee United Kingdom

    lee Active Member

    Joined:
    Feb 2013
    Posts:
    277
    Likes Received:
    3
    I am trying to setup an alias on my domain (printer@mydomain.com) that will forward or send a copy to my Epson Connect email address (myprinter@print.epsonconnect.com) and make it easier for me and my family to remember the address and send documents to our printer from anywhere.

    The problem is that when the email is forwarded it keeps the "printer@mydomain.com" email address as the "to" address and I get a bounceback from epson saying that printer does not exist. Is there a way to forward or send a copy of an email to that "myprinter@print.epsonconnect.com" and make sure that it is the "to" address in Cpanel?
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
     
  3. mrt United Kingdom

    mrt Member

    Joined:
    May 2013
    Posts:
    18
    Likes Received:
    3
    How about something like the below? Simplest way I can think of to change the 'To' address on the email to keep the printer happy.

    Code:
    #!/usr/bin/perl
    use strict;
    
    # Real email address for the printer
    my $email = 'myprinter@print.epsonconnect.com';
    
    my $sm;
    open($sm, "|/usr/sbin/sendmail -t") or die("Got an error but can't open sendmail: $!");
    
    my $in_header = 1;
    
    while (my $line = <STDIN>) {
            chomp $line;
    
            # Empty line while in headers means end of headers
            if ($in_header && $line eq '') {
                    $in_header = 0;
            }
    
            # Replace To: field if we're in headers
            if ($in_header && $line =~ m/^To: /) {
                    $line = "To: $email";
            }
    
            # Pass through to sendmail
            print $sm "$line\n";
    }
    
    close($sm);
    
    • Change the address in line 5 for the real printer email address and save it as say printer.pl
    • Upload it to the root of your cPanel account
    • Give it execute permissions (700)
    • Delete your current printer@ forwarder
    • Add a new forwarder, and this time click 'Advanced Options', put printer.pl into the 'Pipe to a program' field and click the 'Add Forwarder' button to add it
    • Now send an email and hopefully it'll work!

    The script is essentially a really trivial proxy to sendmail that'll modify the 'To' address on the way through.
     
    • Like Like x 1
  4. fabpack United Kingdom

    fabpack Active Member

    Joined:
    Sep 2008
    Posts:
    260
    Likes Received:
    2
    what a wanker you are!
     
Thread Status:
Not open for further replies.

Share This Page