Jump to content

MAIL() function help


wickedgenius

Recommended Posts

I'm learning how to program in PHP using a book and have copied an example for an e-mail form but it doesn't work. It goes to the confirmation page but never sends the e-mail. I have tried this with two different e-mail addresses but no luck at all.

 

In feedback.html I have:

 

<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>

 

Then in sendmail.php I have:

 

<html>
<head>
<title>Mail Sent</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 = "[email protected]";
$subject = "Feedback";
$mailheaders = "From: My Web Site\n";
$mailheaders .= "Reply-To: $_POST[email]";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>

 

Finaly in the Mail function part of PHP.ini I have:

 

[mail function]
; For Win32 only.
SMTP = smtp.mail.yahoo.co.uk
smtp_port = 465

; For Win32 only.
;sendmail_from = [email protected]

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

Link to comment
https://forums.phpfreaks.com/topic/46584-mail-function-help/
Share on other sites

I use this to e-mail with no problems. Maybe it will help.

 

function emailNewPassword($newPass, $user) {
// SEND THE EMAIL
ini_set(sendmail_from, "[email protected]");
$to = getEmail($user);
$subject = "New password for domain.org account";
$body = "Your password has been reset to $newPass. If you think you have received this e-mail by mistake, please contact the webmaster.";
$headers .= "From: Password Reset <[email protected]>\r\n";
mail($to, $subject, $body, $headers);
ini_restore(sendmail_from);
}

 

Let me know how it turns out.

Link to comment
https://forums.phpfreaks.com/topic/46584-mail-function-help/#findComment-226862
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.