Sendmail and Apache problems

Hi everyone, good to be here. This is my first post. Im having problems sending mail with sendmail.

I am building a website in php that needs to be able to send email to external users.

I am using apache2 as my webserver and sendmail as my email server.

I understand SuSE doesnt have a sendmail.mc file. The /etc/sendmail.cf file is generated automaticaly from configuration files in /etc/sysconfig/sendmail and /etc/sysconfig/mail. I have edited these files to include a smart-host and I have successfuly sent email from the command line.

the following is the output from the /var/log/mail log when i send mail from the command
line…

Jun 3 18:35:11 luke sendmail[7697]: n541Z21j007697: to=james.luke318@gmail.com, ctladdr=james (1000/100), delay=00:00:09, xdelay=00:00:04, mailer=relay, pri=30006, relay=shawmail.vc.shawcable.net [64.59.128.135], dsn=2.0.0, stat=Sent (ok: Message 69473869 accepted)

everything works fine. I checked my gmail account and the message is there. The problem I have is when I try to send mail from my website it doesnt work. The following is the log message when I try to send mail from my webpage…

Jun 3 18:38:11 luke sendmail[7718]: n541cBsg007718: from=wwwrun, size=212, class=0, nrcpts=0, msgid=<200906040138.n541cBsg007718@luke.steadydippin.com>, relay=wwwrun@localhost

clearly the relay=wwwrun@localhost is wrong and no email is sent. The PHP code to send the mail is correct, there must something wrong with my sendmail configuration. Can someone tell me why mail is getting realayed to wwwrun@localhost instead of my ISP mail server? maybe I have to edit something in the (local-host-names) or (relay-domains) file??

any help would be greatly appreciated. Thanks.

PS: Im not sure if this helps but this is the output i get when I type (sendmail -d0.11) from the commandline…

Version 8.12.10
Compiled with: DNSMAP EGD LDAPMAP LOG MAP_REGEX MATCHGECOS MILTER
MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6 NETUNIX NEWDB NIS
NISPLUS PIPELINING SASLv2 SCANF STARTTLS TCPWRAPPERS USERDB
USE_LDAP_INIT
OS Defines: ADDRCONFIG_IS_BROKEN HASFCHOWN HASFCHMOD
HASGETDTABLESIZE HASINITGROUPS HASLSTAT HASNICE HASRANDOM
HASRRESVPORT HASSETREGID HASSETREUID HASSETRLIMIT HASSETSID
HASSETVBUF HASURANDOMDEV HASSTRERROR HASUNAME HASUNSETENV
HASWAITPID IDENTPROTO IP_SRCROUTE NEEDSGETIPNODE
REQUIRES_DIR_FSYNC USE_DOUBLE_FORK USE_SIGLONGJMP USESETEUID
Kernel symbols: /boot/vmlinux
Conf file: /etc/mail/submit.cf (default for MSP)
Conf file: /etc/sendmail.cf (default for MTA)
Pid file: /var/run/sendmail.pid (default)
Canonical name: luke.steadydippin.com
a.k.a.: luke
UUCP nodename: luke
a.k.a.: luke
a.k.a.: [192.168.1.104]
Conf file: /etc/mail/submit.cf (selected)
Pid file: /var/spool/clientmqueue/sm-client.pid (selected)

============ SYSTEM IDENTITY (after readcf) ============
(short domain name) $w = luke
(canonical domain name) $j = luke.steadydippin.com
(subdomain name) $m = steadydippin.com
(node name) $k = luke

Recipient names must be specified

shuks wrote:

> Jun 3 18:38:11 luke sendmail[7718]: n541cBsg007718: from=wwwrun,
> size=212, class=0, nrcpts=0,
> msgid=<200906040138.n541cBsg007718@luke.steadydippin.com>,
> relay=wwwrun@localhost

Is there no “To:” (no recipient)? :-?

I would start by checking “php.ini” file setup to see environment values
(php must know where to find sendmail) and the php script itself.

Try with a simple code just to test php mail() function, i.e.:

PHP Simple E-Mail
http://www.w3schools.com/PHP/php_mail.asp

To see if that works.

Greetings,


Camaleón

Thanks for the reply.

Yes, I did edit the php.ini file to include sendmail as the mailer program…

[mail function]
; For Win32 only.
;SMTP = localhost

; For Win32 only.
;sendmail_from = james.luke318@gmail.com

; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
sendmail_path = “/usr/sbin/sendmail”
sendmail_from = “james@luke.steadydippin.com

is there anything wrong with this??

shuks wrote:

> Thanks for the reply.
>
> Yes, I did edit the php.ini file to include sendmail as the mailer
> program…

> ; For Unix only. You may supply arguments as well (default: “sendmail
> -t -i”).
> sendmail_path = “/usr/sbin/sendmail”

Just try by following the advice:

sendmail_path = “/usr/sbin/sendmail -t -i”

Restart apache (rcapache2 restart) and test your script again or some basic
php mail() function.

php errors should be logged into apache’s standard log
(/var/log/apache2/*error_log)

Greetings,


Camaleón

thanks, I tried adding the -t -i option but still didnt work. Any other advice would be great

Is the PHP mail() function connecting to localhost:25 or is it piping the mail to a sendmail process? In the latter case, you will find that you may have to specify the accounts that are allowed to masquerade, i.e. specify any sender in the From: field.

shuks wrote:

> thanks, I tried adding the -t -i option but still didnt work. Any other
> advice would be great

How about logs (sendmail and php ones), what are they saying? :slight_smile:

Have you tried running the basic php test mail() function?

Greetings,


Camaleón

the php mail() function is supposed to be piping mail to sendmail for delivery. When I try to send a mail through my website it generates an input to the /var/log/mail file…

the message is generates is looks the same as the what i copy and pasted in my original message. the variables are all wrong. eg…

from=wwwrun, relay=wwwrun@localhost.

the from value should be the email address of my server, and the relay value should be shawmail.vc.shawcable.net

It works fine when i do it from the command line but not through php mail() function…

can you tell me a bit more about masquerading stuff. that might be the problem.

I’ve only seen it in passing reference. I don’t use sendmail any more so I can’t tell you any more about it.

sendmail masquerading

shuks wrote:

> the php mail() function is supposed to be piping mail to sendmail for
> delivery. When I try to send a mail through my website it generates an
> input to the /var/log/mail file…

Yes, mail is created, but fails…

> the message is generates is looks the same as the what i copy and
> pasted in my original message. the variables are all wrong. eg…
>
> from=wwwrun, relay=wwwrun@localhost.

“From=” is ok.

Well, is the user running Apache, so if you are using Apache to send the
message (i.e., by using a webform script), I think this value is o.k.

“Relay=” is acquiring the username and host combo. I see no problem here,
neither.

I only miss the recipient (“To=”) :-?

> the from value should be the email address of my server, and the relay
> value should be shawmail.vc.shawcable.net

That values should be configurable by the script itself. But unless running
the mailserver in another host, I don’t see the problem. “localhost” should
do the “trick” and forward the mail to local sendmail, as currently does.

> It works fine when i do it from the command line but not through php
> mail() function…
>
> can you tell me a bit more about masquerading stuff. that might be the
> problem.

I know nothing about sendmail, sorry :frowning:

Greetings,


Camaleón

Thanks for all the help. I finally got it working. I had to edit the file /etc/mail/relay-domains, and add my own domain name so that anyone from my domain will get relayed to my ISP’s mail pop3 mail server.