Jump to content

Recommended Posts

Posted

Greetings,

 

I'm using FormHandler.cgi from the CGI/Perl Cookbook to handle forms on my website. When a user enters information, two e-mails are supposed to be sent, one to my business and one to the user to confirm the e-mail. The e-mail to me arrives just fine, but the e-mail to the user does not :) . sendmail is saying that I am trying to relay (wise of it to notice!), and obviously this is not allowed.

 

Surely there is a way to accomplish this. Any ideas?

 

Thanks! :unsure:

 

pagoda

Posted

Can you add the key bits of source code so that we can have a look?

 

My guess is that there is somewhere that you need to let it know you are sending from your domain, and not someone outside of your domain using it as a relay for SPAM.

 

Andy.

Posted

Hi AndyB,

 

This is where the my script is failing:

 

print SMTP "RCPT TO:$address$CRLF";

sysread(SMTP, $_, 1024);

/[^0-9]*(\d\d\d)/;

if ($1 ne '250') { push(@bad_addresses, $name{$address}, $_) }

else { ++$good_addresses }

 

When the value of $address is equal to:

 

-An e-mail with my TCH domain in it (i.e. info@askmegraphics.com),

Then everything works as expected.

 

-An e-mail address other than one with ???@askmegraphics.com,

then it fail with the following message from sendmail:

 

550-server10.totalchoicehosting.com (askmegraphics.com) [209.51.134.50] is

550-currently not permitted to relay through this server. Perhaps you have not

550-logged into the pop/imap server in the last 30 minutes or do not have SMTP

550 Authentication turned on in your email client.

 

Note: $address is the e-mail address being sent _to_. It apparently does not matter where I claim to be sending _from_ so long as the _to_ is an address in the askmegraphics.com domain.

 

I can reliably reproduce this result by manually telnetting to the sendmail port and talking to sendmail. So I must be confused about how to send mail _out_ via a script. Note- my mail goes out just fine from my POP account. Also- the first thing I do to identify myself to sendmail is the following:

 

HELO askmegraphics.com

 

(I also tried explicitely saying "HELO server10.totalchoicehosting.com").

 

I'm sure this is just a simple misunderstanding on my part. Any ideas?

 

Thanks!

 

PS: I'm using mail.askmegraphics.com to create a socket to the sendmail port.

 

pagoda

Posted

Greetings All,

 

Ok, I've made some minimal progress on this:

 

-Using /usr/sbin/sendmail works, even when I send an email to someone outside of my domain (as I am going for).

 

-Attaching to a socket (port 25) from within PERL does not work, using the same "To:" and "From:". (For those interested- a code snippet is at the end of this e-mail.)

 

So- Am I to assume that the exim version of sendmail wraps my messages somehow and allows them to go through, but that doing the same thing directly through a PERL socket is verboten? Looks like it.

 

I'm still hopeful someone will tell me otherwise- mainly because I am lazy :P and don't want to change all the socket references to /usr/sbin/sendmail reference (not impossible- just a hassle).

 

pagoda

 

In the example:

$WEB_SERVER = "askmegraphics.com";

$SMTP_SERVER = "mail.askmegraphics";

 

Everything works fine until a "RCPT TO:" is issued to the open socket that is not a "local" address, i.e. not something@askmegraphics.com.

 

>   local($SMTP_SERVER_PORT) = 25;
   local($AF_INET) = ($] > 5 ? AF_INET : 2);
   local($SOCK_STREAM) = ($] > 5 ? SOCK_STREAM : 1);
   local(@bad_addresses) = ();
   $, = ', ';
   $" = ', ';

   # Translate hostnames to corresponding addresses and pack

   local($local_address) = (gethostbyname($WEB_SERVER))[4];
   local($local_socket_address) = pack('S n a4 x8', $AF_INET, 0, $local_address
);

   local($server_address) = (gethostbyname($SMTP_SERVER))[4];
   local($server_socket_address) = pack('S n a4 x8', $AF_INET, $SMTP_SERVER_PORT, $server_address);

   # Translate protocol name to corresponding number

   local($protocol) = (getprotobyname('tcp'))[2];

   # Make the socket filehandle

   if (!socket(SMTP, $AF_INET, $SOCK_STREAM, $protocol)) {
       $Error_Message = "Could not make socket filehandle ($!).";
       return(1);
   }

   # Give the socket an address

   bind(SMTP, $local_socket_address);

   # Connect to the server

   if (!(connect(SMTP, $server_socket_address))) {
       $Error_Message = "Could not connect to server ($!).";
       return(1);
   }
   # Set the socket to be line buffered

   local($old_selected) = select(SMTP);
   $| = 1;
   select($old_selected);

   # Set regex to handle multiple line strings

   $* = 1;

   # Read first response from server (wait for .75 seconds first)

   select(undef, undef, undef, .75);
   sysread(SMTP, $_, 1024);

   # Initiate a conversation with the server

   print SMTP "HELO $WEB_SERVER$CRLF";
   sysread(SMTP, $_, 1024);
   while (/(^|(\r?\n))[^0-9]*((\d\d\d).*)$/g) { $status = $4; $message = $3}
   if ($status != 250) { $Error_Message = $message; return(3) }

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...