Page 1 of 1

Using localhost to send mail...

Posted: Wed Feb 08, 2012 10:58 pm
by orbdrums
Hello all, I am developing locally and running into a problem sending mail. Here is my code:

<?php
$to = "test@test.net" . "\n";
$subject = "Test" . "\n";
$message = "hello" . "\n";
$from = "test@test.net" . "\n";

$mail_output .= "To: " . $to . "Subject: " . "$subject . "Message: " . $message . "From: " . $from;
echo "<pre>",$mail_output,"</pre>";

mail($to, $subject, $message, $from);
?>

I want to use my home ISP's SMTP server but I don't know where to change the mail configuration lines. I am using MAMP and the php mail() uses my username and localhost name when attempting to connect to my SMTP server. Any suggestions would be greatly appreciated.

Re: Using localhost to send mail...

Posted: Thu Feb 09, 2012 4:14 pm
by daj
the mail() function in PHP is simple to use, and has little configuration. Normally you can only use your localhost to send emails. If you wish to send emails using another mail server (for example, your ISP's mail server) you will need to ensure they allow remote SMTP connections and SMTP authentication.

If this is permitted you can use the PEAR mail script; usually installed on any PHP after version 4.0

There's a good write up here....http://email.about.com/od/emailprogramm ... cation.htm

Re: Using localhost to send mail...

Posted: Thu Feb 09, 2012 4:55 pm
by Celauran
From the PHP manual:
mail configuration
mail()

Re: Using localhost to send mail...

Posted: Thu Feb 09, 2012 10:47 pm
by orbdrums
Maybe I'm complicating this. I am developing a website locally (127.0.0.1) localhost on a MAC. All I need to do is send an email to my ISP account but I can't even get that far. My php script does not error but when I look at my Console log it comes back with the following:
2/9/12 8:41:14 PM postfix/master[29529] daemon started -- version 2.5.14, configuration /etc/postfix
2/9/12 8:41:14 PM postfix/qmgr[29531] 072FB25E69FC: from=<clarkhull@Clark-MacBook.local>, size=473, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 1286F25E04AB: from=<clarkhull@Clark-MacBook.local>, size=569, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 18F4D25E6B17: from=<clarkhull@Clark-MacBook.local>, size=473, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 275A225E3A20: from=<clarkhull@Clark-MacBook.local>, size=380, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 2B40625E539D: from=<clarkhull@Clark-MacBook.local>, size=473, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 4231F25E56FE: from=<clarkhull@Clark-MacBook.local>, size=321, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 424BD25E3A93: from=<clarkhull@Clark-MacBook.local>, size=375, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 485F225E54B4: from=<clarkhull@Clark-MacBook.local>, size=473, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 60AFA25E3BA3: from=<clarkhull@Clark-MacBook.local>, size=362, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 6197C25E06CB: from=<clarkhull@Clark-MacBook.local>, size=569, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 6200025E3B71: from=<clarkhull@Clark-MacBook.local>, size=362, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 7368A25E3D6B: from=<clarkhull@Clark-MacBook.local>, size=344, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 73D0B25E0722: from=<clarkhull@Clark-MacBook.local>, size=569, nrcpt=1 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 8345F25E3AD3: from=<clarkhull@Clark-MacBook.local>, size=367, nrcpt=5 (queue active)
2/9/12 8:41:14 PM postfix/qmgr[29531] 89D8625E1359: from=<clarkhull@Clark-MacBook.local>, size=364, nrcpt=1 (queue active)
2/9/12 8:41:15 PM postfix/qmgr[29531] B68B925E140C: from=<clarkhull@Clark-MacBook.local>, size=364, nrcpt=1 (queue active)
2/9/12 8:41:15 PM postfix/qmgr[29531] BC91125E1586: from=<clarkhull@Clark-MacBook.local>, size=364, nrcpt=1 (queue active)
2/9/12 8:41:15 PM postfix/qmgr[29531] C077425E3B24: from=<clarkhull@Clark-MacBook.local>, size=362, nrcpt=1 (queue active)
2/9/12 8:41:15 PM postfix/qmgr[29531] C88D525E6B4F: from=<clarkhull@Clark-MacBook.local>, size=473, nrcpt=1 (queue active)
2/9/12 8:41:15 PM postfix/qmgr[29531] D5D1825E4160: from=<clarkhull@Clark-MacBook.local>, size=344, nrcpt=5 (queue active)
2/9/12 8:41:15 PM postfix/pickup[29530] B2F1725E6D8F: uid=501 from=<clarkhull>
2/9/12 8:41:15 PM postfix/cleanup[29532] B2F1725E6D8F: message-id=<20120210044115.B2F1725E6D8F@Clark-MacBook.local>
2/9/12 8:41:15 PM postfix/qmgr[29531] B2F1725E6D8F: from=<clarkhull@Clark-MacBook.local>, size=473, nrcpt=1 (queue active)
2/9/12 8:41:45 PM postfix/smtp[29534] connect to mx.east.cox.net[68.1.17.3]:25: Operation timed out
2/9/12 8:41:45 PM postfix/smtp[29537] connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out
2/9/12 8:41:45 PM postfix/smtp[29535] connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out
2/9/12 8:41:45 PM postfix/smtp[29539] connect to mx.east.cox.net[68.1.17.3]:25: Operation timed out
2/9/12 8:41:45 PM postfix/smtp[29538] connect to mx.east.cox.net[68.1.17.3]:25: Operation timed out
2/9/12 8:41:45 PM postfix/smtp[29541] connect to post6.cox.com[24.248.74.39]:25: Operation timed out
2/9/12 8:42:14 PM postfix/master[29529] master exit time has arrived
2/9/12 8:42:15 PM postfix/smtp[29534] connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out
2/9/12 8:42:15 PM postfix/smtp[29534] warning: 072FB25E69FC: defer service failure
2/9/12 8:42:15 PM postfix/smtp[29534] 072FB25E69FC: to=<orbdrums@cox.net>, relay=none, delay=3220, delays=3159/0.05/61/0, dsn=4.4.1, status=deferred (connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out)
2/9/12 8:42:15 PM postfix/smtp[29537] connect to mx.east.cox.net[68.1.17.3]:25: Operation timed out
2/9/12 8:42:15 PM postfix/smtp[29537] warning: 18F4D25E6B17: defer service failure
2/9/12 8:42:15 PM postfix/smtp[29537] 18F4D25E6B17: to=<orbdrums@cox.net>, relay=none, delay=2400, delays=2339/0.08/61/0, dsn=4.4.1, status=deferred (connect to mx.east.cox.net[68.1.17.3]:25: Operation timed out)
2/9/12 8:42:15 PM postfix/smtp[29535] connect to mx.east.cox.net[68.1.17.3]:25: Operation timed out
2/9/12 8:42:15 PM postfix/smtp[29535] warning: 1286F25E04AB: defer service failure
2/9/12 8:42:15 PM postfix/smtp[29535] 1286F25E04AB: to=<bustinballs@cox.net>, relay=none, delay=190171, delays=190109/0.03/61/0, dsn=4.4.1, status=deferred (connect to mx.east.cox.net[68.1.17.3]:25: Operation timed out)
2/9/12 8:42:15 PM postfix/smtp[29539] connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out
2/9/12 8:42:15 PM postfix/smtp[29539] warning: 2B40625E539D: defer service failure
2/9/12 8:42:15 PM postfix/smtp[29539] 2B40625E539D: to=<orbdrums@cox.net>, relay=none, delay=41491, delays=41430/0.09/61/0, dsn=4.4.1, status=deferred (connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out)
2/9/12 8:42:15 PM postfix/smtp[29538] connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out
2/9/12 8:42:15 PM postfix/smtp[29538] warning: 275A225E3A20: defer service failure
2/9/12 8:42:15 PM postfix/smtp[29538] 275A225E3A20: to=<To:orbdrums@cox.net>, relay=none, delay=87452, delays=87391/0.1/61/0, dsn=4.4.1, status=deferred (connect to mx.west.cox.net[68.6.19.3]:25: Operation timed out)
2/9/12 8:42:15 PM postfix/smtp[29541] connect to post1.cox.com[24.248.74.35]:25: Operation timed out
2/9/12 8:42:44 PM mDNSResponder[21] PenaltyTimeForServer: PenaltyTime negative -19806, (server penaltyTime -1968811391, timenow -1968791585) resetting the penalty
2/9/12 8:42:45 PM postfix/smtp[29541] connect to post3.cox.com[24.248.72.35]:25: Operation timed out
2/9/12 8:42:45 PM postfix/smtp[29541] warning: 89D8625E1359: defer service failure
2/9/12 8:42:45 PM postfix/smtp[29541] 89D8625E1359: to=<orbdrums@cox.com>, relay=none, delay=169878, delays=169787/0.07/91/0, dsn=4.4.1, status=deferred (connect to post3.cox.com[24.248.72.35]:25: Operation timed out)

I don't understand how or why it is trying to connect to mx.west.cox.net. Not only that but now I have about 20 messages in my postfix queue that I don't know how to delete.
I'm stumped.

Re: Using localhost to send mail...

Posted: Fri Feb 10, 2012 6:26 am
by Celauran
So the mail() function is working fine. This is a Postfix configuration issue.

Re: Using localhost to send mail...

Posted: Fri Feb 10, 2012 8:21 am
by orbdrums
Yes I believe that to be true but I don't know where to change "mx.west.cox.net" to "smtp.west.cox.net". From the reading that I've done postfix/smtp should default to smtp so I don't know where the "mx" came from unless in stands for MacOSX. I'm guessing. Would you know how I make theses changes?

Re: Using localhost to send mail...

Posted: Fri Feb 10, 2012 8:29 am
by Celauran
mx is mail exchanger. Seeing that is normal.

Re: Using localhost to send mail...

Posted: Fri Feb 10, 2012 8:39 am
by orbdrums
Okay. Now I know what mx is but I still can't send mail to anyone with Terminal. Could this be a port 25 issue with the cox smtp server? Also, every time I use sendmail now I have 22 or 23 messages queued. I can look at them with qmgr but how do I remove these messages from the queue. I'm very new to this so thanks for your patience.