/    Sign up×
Community /Pin to ProfileBookmark

mail() function not working…

I am trying to create feedback form and want to send the content to an email id using the mail(). What should I suppose to do for that?

I tried with some code but it’s not working..

Here is the code

[code=php]

<?php
if (isset($_REQUEST[’email’]))
//if “email” is filled out, send email
{
ini_set(‘SMTP’, “mail.reliconindia.x10.mx”);
ini_set(‘smtp_port’, 5665);
//ini_set(”, “[email protected]”)
//send email
$email = $_REQUEST[’email’] ;
$subject = $_REQUEST[‘subject’] ;
$message = $_REQUEST[‘message’] ;
mail(“[email protected]”, $subject, $message, “From:” . $email);
echo “Thank you for using our mail form”;
}
else
//if “email” is not filled out, display the form
{
echo “<form method=’post’ action=’mailform.php’>
Email: <input name=’email’ type=’text’ /><br />
Subject: <input name=’subject’ type=’text’ /><br />
Message:<br />
<textarea name=’message’ rows=’15’ cols=’40’>
</textarea><br />
<input type=’submit’ />
</form>”;
}
?>
[/code]

For testing I had created a domain using x10hosting.com
It’s not showing any error but mail is not sent to the email id to which I want to send..
Please suggest some solution. Thank you in advance..

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@slyfoxJul 20.2011 — the from email address's domain must be hosted on the server you're sending from, so, use an email address that's the same as the domain you're sending from, then add your $_REQUEST['email'] to the "reply-to" parameter

an example for your convenience:
[code=php]
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "rn" .
'Reply-To: '. $_REQUEST['email'] . "rn" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

[/code]


http://www.w3schools.com/php/php_mail.asp

http://php.net/manual/en/function.mail.php
Copy linkTweet thisAlerts:
@DerokorianJul 20.2011 — Hey sly, I dont mean to be off topic, but why do we use the x-mailer header. I've never understood that O_o
Copy linkTweet thisAlerts:
@slyfoxJul 20.2011 — oh... lol, just did a quick copy and paste from php.net

use it... don't use it... you know
×

Success!

Help @subhra44 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...