__PG__
October 2nd, 2011, 07:35 AM
Hello all. Long time lurker first time poster.
I'm writing a web page for the first time. I'm testing in a MacBook 5,3 running Ubuntu 10.04. I have installed apache and php and everything is working fine, until I get around to testing a php form to send mail.
I have configured php to send mail using gmail as a server. I can send mail from the following script titled 'mailform.php' using php at the command line $> php -f mailform.php
<?php
$to = "myaddress@yahoo.com";
$subject = "Test mail from PHP";
$message = "Hello! This is a simple email message";
$from = "myaddress@gmail.com";
$headers = "From:" . $from;
echo "Headers = $headers\n";
if(mail($to,$subject,$message,$headers)){
echo "Mail Sent.\n";
} else {
echo "Message Failed\n";
}
?>
However I cannot get php to send mail when used as part of a php form. A good example of a test from can be found here: http://apptools.com/phptools/forms/forms1.php
I have dowloaded and ran the file (lesson1.php), amending the email address as necessary. According to the script the mail is sent (i.e. the mail command executes as 'true' and 'Message Sent' is echoed to the browser). However the email never arrives.
Any suggestions as to where to go from here?
The mail log shows the following when attempting to send mail via a form
Oct 2 16:45:56 PagBook sm-mta[3585]: p925juZk003585: from=<www-data@PagBook>, size=525, class=0, nrcpts=1, msgid=<4e87fa57.OnLNLt3lyJjbDMUE%myaddress@gmail.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Oct 2 16:45:56 PagBook sendmail[3554]: p925jtEm003554: to=myaddress@yahoo.com, ctladdr=www-data (33/33), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30377, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p925juZk003585 Message accepted for delivery)
Oct 2 16:45:59 PagBook sm-mta[3587]: p925juZk003585: to=<myaddress@yahoo.com>, ctladdr=<www-data@PagBook> (33/33), delay=00:00:03, xdelay=00:00:03, mailer=esmtp, pri=120525, relay=mta5.am0.yahoodns.net. [74.6.136.65], dsn=5.0.0, stat=Service unavailable
Oct 2 16:45:59 PagBook sm-mta[3587]: p925juZk003585: p925jxZk003587: DSN: Service unavailable
I'm writing a web page for the first time. I'm testing in a MacBook 5,3 running Ubuntu 10.04. I have installed apache and php and everything is working fine, until I get around to testing a php form to send mail.
I have configured php to send mail using gmail as a server. I can send mail from the following script titled 'mailform.php' using php at the command line $> php -f mailform.php
<?php
$to = "myaddress@yahoo.com";
$subject = "Test mail from PHP";
$message = "Hello! This is a simple email message";
$from = "myaddress@gmail.com";
$headers = "From:" . $from;
echo "Headers = $headers\n";
if(mail($to,$subject,$message,$headers)){
echo "Mail Sent.\n";
} else {
echo "Message Failed\n";
}
?>
However I cannot get php to send mail when used as part of a php form. A good example of a test from can be found here: http://apptools.com/phptools/forms/forms1.php
I have dowloaded and ran the file (lesson1.php), amending the email address as necessary. According to the script the mail is sent (i.e. the mail command executes as 'true' and 'Message Sent' is echoed to the browser). However the email never arrives.
Any suggestions as to where to go from here?
The mail log shows the following when attempting to send mail via a form
Oct 2 16:45:56 PagBook sm-mta[3585]: p925juZk003585: from=<www-data@PagBook>, size=525, class=0, nrcpts=1, msgid=<4e87fa57.OnLNLt3lyJjbDMUE%myaddress@gmail.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Oct 2 16:45:56 PagBook sendmail[3554]: p925jtEm003554: to=myaddress@yahoo.com, ctladdr=www-data (33/33), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30377, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p925juZk003585 Message accepted for delivery)
Oct 2 16:45:59 PagBook sm-mta[3587]: p925juZk003585: to=<myaddress@yahoo.com>, ctladdr=<www-data@PagBook> (33/33), delay=00:00:03, xdelay=00:00:03, mailer=esmtp, pri=120525, relay=mta5.am0.yahoodns.net. [74.6.136.65], dsn=5.0.0, stat=Service unavailable
Oct 2 16:45:59 PagBook sm-mta[3587]: p925juZk003585: p925jxZk003587: DSN: Service unavailable