Jump to content

Recommended Posts

Ok, for a software website I'm creating, I need to create a mail form. To do this, I just downloaded a simple mail example from this website and edited it a bit. Here's the form I created:

[code="email.php"]<html>
<head>
<title>Comment...</title>
</head>

<body>

<form action="email-guts.php">

<center><b>Nickname:</b></center><br/>
<center><input type="text" name="nickname" value="Your name/nickname"/></center><br/><br/>

<center><b>E-mail:</b></center><br />
<center><input type="text" name="email" value="Your E-mail"/></center><br/><br/>

<center><b>Message:</b></center><br/>
<center><textarea name="message" rows="5" cols="50"></textarea></center><br />

<center><input type="hidden" name="ip" value="<? echo $REMOTE_ADDR; ?>" /></center>

<center>
<input name="Submit" type="submit" value="Submit" />
<input name="Submit" type="reset" value="Reset" />
</center>

</form>

</body>
</html>[/code]

...and connected it to email-guts.php:

[code="email-guts.php"]<?
$yourwebsite = "http://FIF1217.no-ip.org"; // Your website
$recipientname = "FIF1217 Software Admin"; // Whats your name ?!
$subject="FIF1217 Software Website";  // The subject of the mail thats being sended
$recipient="FIF1217Software+form@gmail.com"; // the recipient
$completetion_message="Thanks for sending us your comments!";

/*
  The headers for the e-mail, no need to change it unless you know what you're doing
*/
$header = "From: $nickname <$email>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$header .= "X-Priority: 3\r\n";
$header .= "X-MSMail-Priority: Normal\r\n";
$header .= "X-Mailer: PHP / ".phpversion()."\r\n";

/*
  You can change the text below to whatever you wish to have
  for the way the mail is gonne be outputted, you can use HTML!
*/
$content= "
Dear $recipientname, $nickname has sended you an e-mail from $yourwebsite.<br><br>
<b>Message:</b>
$message
<hr noshade=\"true\" size=\"1\" color=\"#000000\" />
You can contact $nickname back at $email.";

// Lets send the e-mail by using the mail() function, no need to change below...this can be edited above!
mail($recipient, $content, $header);

// Message the user will see if the e-mail is succesfully sended :)
echo "Thanks for sending your message!";
?>[/code]

But every time that I try testing it out, it says that it submitted it (as I have taken out the original error code), but when I check my mail, it shows nothing!

Is there something in php that should be changed to allow mail to be sent? Or something like that?

Thanks,
FlyingIsFun1217
Link to comment
https://forums.phpfreaks.com/topic/29166-help-with-mail/
Share on other sites

[code]
<?
$yourwebsite = "http://FIF1217.no-ip.org"; // Your website
$recipientname = "FIF1217 Software Admin"; // Whats your name ?!
$subject="FIF1217 Software Website";  // The subject of the mail thats being sended
$recipient="FIF1217Software+form@gmail.com"; // the recipient
$completetion_message="Thanks for sending us your comments!";
$email = $_POST['email'];
$nickname = $_POST['nickname'];

/*
  The headers for the e-mail, no need to change it unless you know what you're doing
*/
$header = "From: $nickname <$email>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$header .= "X-Priority: 3\r\n";
$header .= "X-MSMail-Priority: Normal\r\n";
$header .= "X-Mailer: PHP / ".phpversion()."\r\n";

/*
  You can change the text below to whatever you wish to have
  for the way the mail is gonne be outputted, you can use HTML!
*/
$content= "
Dear $recipientname, $nickname has sended you an e-mail from $yourwebsite.<br><br>
<b>Message:</b>
$message
<hr noshade=\"true\" size=\"1\" color=\"#000000\" />
You can contact $nickname back at $email.";

// Lets send the e-mail by using the mail() function, no need to change below...this can be edited above!
//mail($recipient, $content, $header);

if (mail($recipient, $subject, $content, $header))
{
// Message the user will see if the e-mail is succesfully sended :)
echo "Thanks for sending your message!";
}
else
{
echo "Failed Sending message";
}
?>[/code]

Copy paste this over email-guts.php and try!
Link to comment
https://forums.phpfreaks.com/topic/29166-help-with-mail/#findComment-133717
Share on other sites

Try one off of PHPs site

[code]<?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);
?>[/code]

Change the top two vars and test... if it fails then contact your host.
Link to comment
https://forums.phpfreaks.com/topic/29166-help-with-mail/#findComment-133775
Share on other sites

;) My host is me, I'm using the abyss web server...

Before I was using Apache, which wasn't very helpful, but now that I am using abyss, its gives me this for an error message:

[quote]Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\Abyss Web Server\htdocs\Current_Website\email-guts.php on line 34
Failed Sending message[/quote]

Thanks again!
FlyingIsFun1217
Link to comment
https://forums.phpfreaks.com/topic/29166-help-with-mail/#findComment-133860
Share on other sites

From what I can see it shows $recipient="FIF1217Software+form@gmail.com"; which is what the message is getting sent to. As far as I know the "+" symbol most the time takes the place of a space...which i know for sure that email addresses cant have any special characters of. make sure that it says your full email address and try again. Let me know if it works!

Link to comment
https://forums.phpfreaks.com/topic/29166-help-with-mail/#findComment-134642
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.