Difficulty with simple send mail
Posted: Mon Dec 29, 2008 12:18 pm
I'm having difficulty getting a very simple feedback responder to work. This is my first attempt to use the mail function. The echo to my screen seems to work OK, but nothing seems to make it to my ISP. I have a feeling that I'm failing an authentication process, but don't know where to look or how to provide whatever is needed(password?).
My Outlook settings(which work) show:
Outgoing mail server (SMTP) : smtp.att.yahoo.com
Advanced settings Server Port Numbers Outgoing: 465
This server requires an encrypted connection (SSL)
I've modified my php.ini to include the following:
[mail function]
; For Win32 only.
SMTP = smtp.att.yahoo.com
smtp_port = 465
; For Win32 only.
sendmail_from = gsinkinson@att.net
My HTML form looks like:
My PHP looks like:
My Outlook settings(which work) show:
Outgoing mail server (SMTP) : smtp.att.yahoo.com
Advanced settings Server Port Numbers Outgoing: 465
This server requires an encrypted connection (SSL)
I've modified my php.ini to include the following:
[mail function]
; For Win32 only.
SMTP = smtp.att.yahoo.com
smtp_port = 465
; For Win32 only.
sendmail_from = gsinkinson@att.net
My HTML form looks like:
Code: Select all
<html>
<head>
<title>E-Mail Form</title>
</head>
<body>
<form action="sendmail.php" method="POST">
<p><strong>Name:</strong><br/> <input type="text" size="25" name="name"/></p>
<p><strong>E-Mail Address:</strong><br/> <input type="text" size="25" name="email"/></p>
<p><strong>Message:</strong><br/>
<textarea name="message" cols="30" rows="5"></textarea></p>
<p><input type="submit" value="send"/></p>
</form>
</body>
</html>Code: Select all
<html>
<head>
<title> Sending mail from the form in Listing 11.10</title>
</head>
<body>
<?php
echo "<p>Thank you, <b>".$_POST["name"]."</b>, for your message!</p>";
echo "<p>Your e-mail address is: <b>".$_POST["email"]."</b>.</p>";
echo "<p>Your message was:<br />";
echo $_POST["message"]." </p>";
//start building the mail string
$msg = "Name: ".$_POST["name"]."\n";
$msg .= "E-Mail: ".$_POST["email"]."\n";
$msg .= "Message: ".$_POST["message"]."\n";
//set up the mail
$recipient = "gsinkinson@att.net";
$subject = "Form Submission Results";
$mailheaders = "From: My Web Site <defaultaddress@yourdomain.com> \n";
$mailheaders .= "Reply-To: ".$_POST["email"];
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>