Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > HOWTO-Related Questions

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 21st April 2006, 01:04
linuxuser1 linuxuser1 is offline
Member
 
Join Date: Oct 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default sending e-mail using mail() function

How can i set up my debian servers - one with postfix and 1 with sendmail to allow a php script to use the mail() function to send e-mail. Both servers have ISPConfig installed.

What i have in my php.ini =
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail

The php.ini is located at /etc/php4/apache2/php.ini


Thanks

Last edited by linuxuser1; 21st April 2006 at 07:55.
Reply With Quote
Sponsored Links
  #2  
Old 21st April 2006, 11:39
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

The mail() function should work out of the box. You don't have to configure anything.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 21st April 2006, 11:52
linuxuser1 linuxuser1 is offline
Member
 
Join Date: Oct 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Falko,

The problem is I have 2 scripts and non of them works. I have vbulletin and 2 other ones. For Vbulleting I have to ask it to use smtp before it can work. For one of the other scripts I also have to specify an SMTP before it can work just like VBulletin but for the other one, there is no where to set an SMTP and I have been trying to get it to work with no progress which is why I
have to uncomment as sendmail_path = /usr/sbin/sendmail thinking this will help but unfortunately it still does not work.

Thanks as always.
Reply With Quote
  #4  
Old 21st April 2006, 17:51
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

How did you install PHP? Did you compile it from the sources, or did you install your distribution's preconfigured packages? Do you have Postfix or Sendmail installed?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 21st April 2006, 18:16
linuxuser1 linuxuser1 is offline
Member
 
Join Date: Oct 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Falko,

I used your debian perfect set up - (http://www.falkotimme.com/howtos/per...arge/index.php) to install both servers. I used your sendmail perfect set up to install sendmail (http://www.falkotimme.com/howtos/sen..._tls/index.php )and both servers have Ispconfig working very well. I used your perfect setup to install Postfix on another one. When I tried using the mail() function in Postfix and it did not work, I then went to try sendmail and its still the same problem.

Should the mail() function work right away after following your perfect setup or i should have done something else tomake it work.

Please help and many thanks.
Reply With Quote
  #6  
Old 21st April 2006, 18:37
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,126
Thanks: 4
Thanked 43 Times in 40 Posts
Default

For testing I would suggest to use the mail() examples in the php doc. If they don't work then there's some issue:

Quote:
Example 907. Sending mail.
Using mail() to send a simple email:

copy to clipboard
<?php
// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('caffinated@example.com', 'My Subject', $message);
?>
Example 908. Sending mail with extra headers.
The addition of basic headers, telling the MUA the From and Reply-To addresses:

copy to clipboard
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
Example 909. Sending mail with an additional command line parameter.
The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path.

copy to clipboard
<?php
mail('nobody@example.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');
?>
Example 910. Sending HTML email
It is also possible to send HTML email with mail().

copy to clipboard
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>
Reply With Quote
  #7  
Old 22nd April 2006, 16:41
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

Quote:
Originally Posted by linuxuser1
Should the mail() function work right away after following your perfect setup or i should have done something else tomake it work.
It should work right away. Do you get errors when you use the mail() function (also look in the mail log)?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #8  
Old 25th April 2006, 01:29
linuxuser1 linuxuser1 is offline
Member
 
Join Date: Oct 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Falko,

Mail log as requested

Apr 24 22:59:36 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 24 22:59:36 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 24 22:59:36 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: server SMTP socket wedged: exiting
Apr 24 23:17:21 mailx sendmail[1678]: NOQUEUE: SYSERR(www-data): can not write to queue directory /var/spool/clientmqueue/ (RunAsGid=0, required=1001): Permission denied
Apr 25 00:00:04 mailx authdaemond.plain: restarting authdaemond children
Apr 25 00:00:04 mailx authdaemond.plain: modules="authpam", daemons=5
Apr 25 00:01:09 mailx authdaemond.plain: modules="authpam", daemons=5
Apr 25 00:01:13 mailx sendmail[1273]: starting daemon (8.13.6): SMTP+queueing@01:00:00
Apr 25 00:01:13 mailx sendmail[1273]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:01:13 mailx sendmail[1273]: daemon MTA: problem creating SMTP socket
Apr 25 00:01:15 mailx sendmail[1307]: k3ON1FvG001307: from=root, size=1567, class=0, nrcpts=1, msgid=<200604242301.k3ON1FvG001307@mailx.cjahostin g.com>, relay=root@localhost
Apr 25 00:01:15 mailx sendmail[1307]: k3ON1FvG001307: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31567, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (OK id=1FYA3P-0000L6-IM)
Apr 25 00:01:18 mailx sendmail[1273]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:01:18 mailx sendmail[1273]: daemon MTA: problem creating SMTP socket
Apr 25 00:01:23 mailx sendmail[1273]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:01:23 mailx sendmail[1273]: daemon MTA: problem creating SMTP socket
Apr 25 00:01:38 mailx sendmail[1273]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:01:38 mailx sendmail[1273]: daemon MTA: problem creating SMTP socket
Apr 25 00:01:48 mailx sendmail[1273]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:01:48 mailx sendmail[1273]: daemon MTA: problem creating SMTP socket
Apr 25 00:01:48 mailx sendmail[1371]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:01:48 mailx sendmail[1371]: daemon MTA: problem creating SMTP socket
Apr 25 00:01:53 mailx sendmail[1273]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:01:53 mailx sendmail[1273]: daemon MTA: problem creating SMTP socket
Apr 25 00:02:13 mailx sendmail[1371]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:02:14 mailx sendmail[1371]: daemon MTA: problem creating SMTP socket
Apr 25 00:02:14 mailx sendmail[1371]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: server SMTP socket wedged: exiting
Apr 25 00:08:05 mailx authdaemond.plain: restarting authdaemond children
Apr 25 00:08:05 mailx authdaemond.plain: modules="authpam", daemons=5
Apr 25 00:09:13 mailx authdaemond.plain: modules="authpam", daemons=5
Apr 25 00:09:17 mailx sendmail[1272]: starting daemon (8.13.6): SMTP+queueing@01:00:00
Apr 25 00:09:17 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:17 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:22 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:22 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:32 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:32 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:36 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:36 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:37 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:37 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:41 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:41 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:42 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:42 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:46 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:46 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:47 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:47 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:51 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:51 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:52 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:52 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:56 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:56 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:09:57 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:09:57 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:10:01 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:10:01 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:10:02 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:10:02 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:10:06 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:10:06 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:10:07 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:10:07 mailx sendmail[1272]: daemon MTA: problem creating SMTP socket
Apr 25 00:10:07 mailx sendmail[1272]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: server SMTP socket wedged: exiting
Apr 25 00:10:11 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:10:11 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:10:16 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Apr 25 00:10:16 mailx sendmail[1358]: daemon MTA: problem creating SMTP socket
Apr 25 00:10:16 mailx sendmail[1358]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: server SMTP socket wedged: exiting
Apr 25 00:16:30 mailx sendmail[1636]: NOQUEUE: SYSERR(www-data): can not write to queue directory /var/spool/clientmqueue/ (RunAsGid=0, required=1001): Permission denied
Apr 25 00:22:11 mailx courierpop3login: Connection, ip=[::ffff:127.0.0.1]
Apr 25 00:22:11 mailx courierpop3login: LOGIN, user=web1_alpharadiotv, ip=[::ffff:127.0.0.1]
Apr 25 00:22:11 mailx courierpop3login: LOGOUT, user=web1_alpharadiotv, ip=[::ffff:127.0.0.1], top=0, retr=0, time=0
Apr 25 00:22:48 mailx courierpop3login: Connection, ip=[::ffff:127.0.0.1]
Apr 25 00:22:48 mailx courierpop3login: LOGIN, user=web1_alpharadiotv, ip=[::ffff:127.0.0.1]
Apr 25 00:22:48 mailx courierpop3login: LOGOUT, user=web1_alpharadiotv, ip=[::ffff:127.0.0.1], top=0, retr=0, time=0


Thanks
Reply With Quote
  #9  
Old 25th April 2006, 16:18
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

You have a problem with Sendmail, not with PHP's mail() function.
What's the output of
Code:
netstat -tap
?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #10  
Old 25th April 2006, 16:31
linuxuser1 linuxuser1 is offline
Member
 
Join Date: Oct 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

mailx:~# netstat -tap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:imaps *:* LISTEN 1 103/couriertcpd
tcp 0 0 *op3s *:* LISTEN 1 126/couriertcpd
tcp 0 0 localhost.localdo:mysql *:* LISTEN 1 220/mysqld
tcp 0 0 *op3 *:* LISTEN 1 112/couriertcpd
tcp 0 0 *:imap2 *:* LISTEN 1 089/couriertcpd
tcp 0 0 *:www *:* LISTEN 1 352/apache2
tcp 0 0 *:81 *:* LISTEN 1 319/ispconfig_http
tcp 0 0 *:ftp *:* LISTEN 1 397/proftpd: (acce
tcp 0 0 virtual-ip1.cjah:domain *:* LISTEN 1 382/named
tcp 0 0 europa.cjahostin:domain *:* LISTEN 1 382/named
tcp 0 0 localhost.locald:domain *:* LISTEN 1 382/named
tcp 0 0 *:ssh *:* LISTEN 1 280/sshd
tcp 0 0 localhost.localdoma:953 *:* LISTEN 1 382/named
tcp 0 0 localhost.localdom:smtp *:* LISTEN 1 160/exim4
tcp 0 0 *:https *:* LISTEN 1 352/apache2
tcp 0 0 virtual-ip1.cjahost:www cjahosting.plus.co:7161 FIN_WAIT2 2223/apache2
tcp 0 2076 europa.cjahosting.c:ssh 192.168.21.18:2450 ESTABLISHED6702/0
mailx:~#


Thanks so much.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Not receiving any incoming mail. Jcorrea920 General 11 3rd April 2010 13:08
Filtering emails using Spamassassin and Clamav for Exchange 2000 Server Rocky Server Operation 19 11th March 2008 08:27
Ispconfig + FC4 + mail function vocoder General 15 10th March 2006 12:36
Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAs ebbay Installation/Configuration 9 4th March 2006 11:47
Problem sending mail to 2nd SMTP server inside network kisong Server Operation 2 2nd March 2006 18:05


All times are GMT +2. The time now is 08:52.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.