Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

configuring sendmail to relay to my isp smtp server address

Status
Not open for further replies.

ramBB

Technical User
Oct 26, 2003
6
BE
Hello everybody

Sorry if my english is not perfect.

I run a linux/apache/php/mysql server and I wanted to send mail through php with the mail function
It didn't work ;)

After a few search on the web, i knew php use sendmail

in my /etc/php.ini file there is :
Code:
sendmail_path = /usr/sbin/sendmail -t -i

to test sendmail, i did (i replaced the email address) :
Code:
echo "test" | /usr/sbin/sendmail  -t -i rambo@ulb.ac.be
it didn't work either and with the -v option it said:

Code:
rambo@ulb.ac.be... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.12.8/8.12.8; Sun, 26 Oct 2003 19:54:35 +0100
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello Ordi1 [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From:<ramb@localhost.localdomain> SIZE=5
250 2.1.0 <ramb@localhost.localdomain>... Sender ok
>>> RCPT To:<rambo@ulb.ac.be>
>>> DATA
250 2.1.5 <rambo@ulb.ac.be>... Recipient ok
354 Enter mail, end with &quot;.&quot; on a line by itself
>>> .
250 2.0.0 h9QIsZZD001289 Message accepted for delivery
rambo@ulb.ac.be... Sent (h9QIsZZD001289 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection


After that command with the mail program i got this mail :

Code:
From MAILER-DAEMON@localhost.localdomain  Sun Oct 26 19:16:22 2003
Date: Sun, 26 Oct 2003 19:16:22 +0100
From: Mail Delivery Subsystem <MAILER-DAEMON@localhost.localdomain>
To: <ramb@localhost.localdomain>
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
        boundary=&quot;h9QIGMZD001202.1067192182/localhost.localdomain&quot;
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)

This is a MIME-encapsulated message

--h9QIGMZD001202.1067192182/localhost.localdomain

The original message was received at Sun, 26 Oct 2003 19:16:21 +0100
from Compu1 [127.0.0.1]

   ----- The following addresses had permanent fatal errors -----
<rambo@ulb.ac.be>
(reason: 553 <ramb@localhost.localdomain>... Please use an existing source domain name.)

   ----- Transcript of session follows -----
... while talking to mailhost.ulb.ac.be.:
>>> MAIL From:<ramb@localhost.localdomain> SIZE=287
<<< 553 <ramb@localhost.localdomain>... Please use an existing source domain name.
501 5.6.0 Data format error

--h9QIGMZD001202.1067192182/localhost.localdomain
Content-Type: message/delivery-status

Reporting-MTA: dns; localhost.localdomain
Received-From-MTA: DNS; Compu1
Arrival-Date: Sun, 26 Oct 2003 19:16:21 +0100

Final-Recipient: RFC822; rambo@ulb.ac.be
Action: failed
Status: 5.1.3
Diagnostic-Code: SMTP; 553 <ramb@localhost.localdomain>... Please use an existing source domain name.
Last-Attempt-Date: Sun, 26 Oct 2003 19:16:22 +0100

--h9QIGMZD001202.1067192182/localhost.localdomain
Content-Type: message/rfc822

Return-Path: <ramb@localhost.localdomain>
Received: from localhost.localdomain (Compu1 [127.0.0.1])
        by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h9QIGLZD001200;
        Sun, 26 Oct 2003 19:16:21 +0100
Received: (from ramb@localhost)
        by localhost.localdomain (8.12.8/8.12.8/Submit) id h9QIGLEA001198;
        Sun, 26 Oct 2003 19:16:21 +0100
Date: Sun, 26 Oct 2003 19:16:21 +0100
From: ramb<ramb@localhost.localdomain>
Message-Id: <200310261816.h9QIGLEA001198@localhost.localdomain>

test

--h9QIGMZD001202.1067192182/localhost.localdomain--

So i thought it didn't work because sendmail don't know my isp smtp server

After a &quot;man sendmail&quot; i found nothing to specify it (i also tried the -G option (we never know))
So i look at the configuration files in /etc/mail
In the /etc/mail/access file i have :

Code:
localhost.localdomain           RELAY
localhost                       RELAY
127.0.0.1                       RELAY

which should be ok because i just want to send mail from my computer
domaintable, virtusertable and mailertable are empty

so i search again on the web and find maybe postfix is the solution
i looked in /etc/postfix
the main.cf was interesting
i added the line
Code:
relayhost=relay.skynet.be
then i rebooted ... but it didn't change nothing

the file /etc/postfix/access is completely commented

as root when i do /usr/sbin/postfix check, i get:
Code:
postfix: warning: My hostname Compu1 is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf
postsuper: warning: My hostname Compu1 is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf

So my questions are :

1. What does sendmail and postfix do? (and what are the relations between them?)
2. Does evolution (or another mail client) use sendmail ? (because it works)
3. How to configure sendmail (or postfix) to send the mails through my isp smtp server
4. Is there another solution to send these mails ?

Thanks a lot
ramBB
 
finally i found a solution without using sendmail:

in fact, you can define your own mail function in php.
grey post it at php.net

Code:
<?php

function socketmail($toArray, $subject, $message) {
  // $toArray format --> array(&quot;Name1&quot; => &quot;address1&quot;, &quot;Name2&quot; => &quot;address2&quot;, ...)

  ini_set(sendmail_from, &quot;myemail@address.com&quot;);

  $connect = fsockopen (ini_get(&quot;SMTP&quot;), ini_get(&quot;smtp_port&quot;), $errno, $errstr, 30) or die(&quot;Could not talk to the sendmail server!&quot;); 
    $rcv = fgets($connect, 1024); 

  fputs($connect, &quot;HELO {$_SERVER['SERVER_NAME']}\r\n&quot;);
    $rcv = fgets($connect, 1024); 

  while (list($toKey, $toValue) = each($toArray)) {

    fputs($connect, &quot;MAIL FROM:myemail@address.com\r\n&quot;); 
      $rcv = fgets($connect, 1024); 
    fputs($connect, &quot;RCPT TO:$toValue\r\n&quot;); 
      $rcv = fgets($connect, 1024); 
    fputs($connect, &quot;DATA\r\n&quot;); 
      $rcv = fgets($connect, 1024); 

    fputs($connect, &quot;Subject: $subject\r\n&quot;); 
    fputs($connect, &quot;From: My Name <myemail@address.com>\r\n&quot;); 
    fputs($connect, &quot;To: $toKey  <$toValue>\r\n&quot;); 
    fputs($connect, &quot;X-Sender: <myemail@address.com>\r\n&quot;); 
    fputs($connect, &quot;Return-Path: <myemail@address.com>\r\n&quot;); 
    fputs($connect, &quot;Errors-To: <myemail@address.com>\r\n&quot;); 
    fputs($connect, &quot;X-Mailer: PHP\r\n&quot;); 
    fputs($connect, &quot;X-Priority: 3\r\n&quot;); 
    fputs($connect, &quot;Content-Type: text/plain; charset=iso-8859-1\r\n&quot;); 
    fputs($connect, &quot;\r\n&quot;); 
    fputs($connect, stripslashes($message).&quot; \r\n&quot;); 

    fputs($connect, &quot;.\r\n&quot;); 
      $rcv = fgets($connect, 1024); 
    fputs($connect, &quot;RSET\r\n&quot;); 
      $rcv = fgets($connect, 1024); 
  }

  fputs ($connect, &quot;QUIT\r\n&quot;); 
    $rcv = fgets ($connect, 1024); 
  fclose($connect);
  ini_restore(sendmail_from);
}
?>

but i am still curious about my sendmail problem
so if somebody know how to answer one of my questions, help will be really appreciated

ramBB
 
I'm not sure about your logging etc. but focusing on the header of this mail :

enter a smart relay host in your sendmail.cf :

DSmailserver.provider.com
 
Editing the sendmail.cf file directly is not something you really should be doing. It is recommended that you edit the sendmail.mc file and generate the cf file using the m4 preprocessor.

There is no God, only 10001010
 
You're right Rhinokiller, but in this case it's just like:

Don't use sendmail, use this mailserver.... Any othere settings will be more or less ignored because it will relay through another server....
it's safe :)
 
Thanks for you answers

so i did what weppie told me, so in my sendmail.cf :

# &quot;Smart&quot; relay host (may be null)
DSrelay.skynet.be

then i restarted sendmail
/etc/init.d/sendmail restart

but it didn't change nothing
(in fact that helped me a lot because i didn't know what was a smart host)

then i tried to modify the sendmail.mc
and i added

define(`SMART_HOST',`relay.skynet.be')dnl

next i did
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

but i receive the error:
/etc/mail/sendmail.mc:10: m4: Cannot open /usr/share/sendmail-cf/m4/cf.m4: Aucun fichier ou répertoire de ce type

after searching the web i knew i had to install &quot;sendmail-cf&quot; so i went to rpmfind.net (because i'm on redhat) to take it and install it

i did again
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
and no error appeared

i restarted sendmail again but my problem was still there
now i will read the doc file

/usr/share/sendmail-cf/README
to try to find a solution here

thanks again for your help
 
i just used the program &quot;ethereal&quot; (a packet sniffer) to see what happened when i did

echo &quot;test&quot; | /usr/sbin/sendmail -t -i somebody@skynet.be

and i filtered the results to the SMTP protocol
here i what i got: ( <-- : receiving/ --> : sending )

<-- Response: 220 september.skynet.be ESMTP .....
--> Command: EHLO localhost.localdomain
<-- Response: 250 .... pleased to meet you
--> Command: MAIL From:<myname@localhost.localdomain> ....
<-- Response: 553 5.1.8 <myname@localhost.localdomain>...
Domain of sender address myname@localhost.localdomain
does not exist
--> Command: QUIT
<-- Response: 221 ... closing connection

so the problem seem to be that my domain is not defined
i'm still searching
 

i tried with the -f option of sendmail
echo &quot;test&quot; | /usr/sbin/sendmail -t -i somebody@skynet.be -f myadress@skynet.be

and now it's working !

thanks again for all your help

ramBB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top