473,473 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Email Problem using PHP

16 New Member
I am attempting to send and email via my feedback form and nothing seems to go thru. I have tried sending to a yahoo account and a gmail account. I have changed a few things in my script several times and did receive a couple emails about 1 day later that just went into bulk. As of now I receive nothing. Can someone please take a look at my script and tell me what I am doing wrong. Also how do I prevent mails from going to bulk/spam? Could this be an issue with my web hosting company ?

Form.php
[php]
<form method="post" action="sendfeedback.php">
<div align="center">
<p align="center"><font face='Verdana' >Contact Us</font> </p>
<p>Feedback<br>
<textarea name="message" rows="5" cols="50"></textarea></p>
<p>Your Email:
<input name="email" type="text" /></p>
<p><input type="submit" value="Send Feedback" /></p>
</div>
</form>


SendFeedback.php

<?php

//get the senders email

$from = $_REQUEST['email'] ;

//define the receiver of the email

$to = 'support@mysite.com';

// subject of the email

$subject = 'Feedback Form Results';

//define the message to be sent.

$message = $_REQUEST['message'] ;

//define the headers

$headers = "From: '$from'\r\nReply-To: '$from' ";

//send the email

$mail_sent = @mail( $to, $subject, $message, $headers );

echo $mail_sent ? "<br><font face='Verdana' size='3' color='green'>Mail sent, Thank You for your Feedback</font>" : "<br><font face='Verdana' size='3' color='green'>Mail failed</font>";

?>[/php]
Feb 20 '08 #1
11 1866
nomad
664 Recognized Expert Contributor
I am attempting to send and email via my feedback form and nothing seems to go thru. I have tried sending to a yahoo account and a gmail account. I have changed a few things in my script several times and did receive a couple emails about 1 day later that just went into bulk. As of now I receive nothing. Can someone please take a look at my script and tell me what I am doing wrong. Also how do I prevent mails from going to bulk/spam? Could this be an issue with my web hosting company ?

Form.php

<form method="post" action="sendfeedback.php">
<div align="center">
<p align="center"><font face='Verdana' >Contact Us</font> </p>
<p>Feedback<br>
<textarea name="message" rows="5" cols="50"></textarea></p>
<p>Your Email:
<input name="email" type="text" /></p>
<p><input type="submit" value="Send Feedback" /></p>
</div>
</form>


SendFeedback.php

<?php

//get the senders email

$from = $_REQUEST['email'] ;

//define the receiver of the email

$to = 'support@mysite.com';

// subject of the email

$subject = 'Feedback Form Results';

//define the message to be sent.

$message = $_REQUEST['message'] ;

//define the headers

$headers = "From: '$from'\r\nReply-To: '$from' ";

//send the email

$mail_sent = @mail( $to, $subject, $message, $headers );

echo $mail_sent ? "<br><font face='Verdana' size='3' color='green'>Mail sent, Thank You for your Feedback</font>" : "<br><font face='Verdana' size='3' color='green'>Mail failed</font>";

?>
This is not right.
$to = 'support@mysite.com';
$subject = 'Feedback Form Results';

try this instead
$EmailTo = "support@mysite.com";
$subject = "Feedback Form Results";

then
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");


nomad
ps I think
echo $mail_sent ? statement is wrong to....
Feb 20 '08 #2
ronverdonk
4,258 Recognized Expert Specialist
Next time enclose any code within the proper code tags. See the Posting Guidelines on how to do that.

moderator
Feb 20 '08 #3
phpmind
16 New Member
Tried what you gave me. Still no email. Any other suggestions are appreciated.
Feb 20 '08 #4
nomad
664 Recognized Expert Contributor
I am attempting to send and email via my feedback form and nothing seems to go thru. I have tried sending to a yahoo account and a gmail account. I have changed a few things in my script several times and did receive a couple emails about 1 day later that just went into bulk. As of now I receive nothing. Can someone please take a look at my script and tell me what I am doing wrong. Also how do I prevent mails from going to bulk/spam? Could this be an issue with my web hosting company ?

Form.php
[php]
<form method="post" action="sendfeedback.php">
<div align="center">
<p align="center"><font face='Verdana' >Contact Us</font> </p>
<p>Feedback<br>
<textarea name="message" rows="5" cols="50"></textarea></p>
<p>Your Email:
<input name="email" type="text" /></p>
<p><input type="submit" value="Send Feedback" /></p>
</div>
</form>


SendFeedback.php

<?php

//get the senders email

$from = $_REQUEST['email'] ;

//define the receiver of the email

$to = 'support@mysite.com';

// subject of the email

$subject = 'Feedback Form Results';

//define the message to be sent.

$message = $_REQUEST['message'] ;

//define the headers

$headers = "From: '$from'\r\nReply-To: '$from' ";

//send the email

$mail_sent = @mail( $to, $subject, $message, $headers );

echo $mail_sent ? "<br><font face='Verdana' size='3' color='green'>Mail sent, Thank You for your Feedback</font>" : "<br><font face='Verdana' size='3' color='green'>Mail failed</font>";

?>[/php]
Not sure if php is case-senative
Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="sendfeedback.php">
change to
Expand|Select|Wrap|Line Numbers
  1.  <form method="POST" action="SendFeedback.php">
this might be wrong
Expand|Select|Wrap|Line Numbers
  1. <input type="submit" value="Send Feedback" />
try this
Expand|Select|Wrap|Line Numbers
  1. <input type="submit" name="submit" value="Submit">
you might want to add this section after you posted data into local variables.
Expand|Select|Wrap|Line Numbers
  1. // validation
  2. $validationOK=true;
  3. if (!$validationOK) {
  4.   print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  5.   exit;
  6. }
Which brings up at matter you have no $_POST sections.



still not to sure about this part
echo $mail_sent ? "<br><font face='Verdana' size='3' color='green'>Mail sent, Thank You for your Feedback</font>" : "<br><font face='Verdana' size='3' color='green'>Mail failed</font>";


nomad
Feb 20 '08 #5
phpmind
16 New Member
I contacted my web hosting company and their is a piece of code they gave me that has to be inserted before the mail( ) function. Wish I knew this before. Thanks for your help ! It is working now.
Feb 20 '08 #6
nomad
664 Recognized Expert Contributor
I contacted my web hosting company and their is a piece of code they gave me that has to be inserted before the mail( ) function. Wish I knew this before. Thanks for your help ! It is working now.

Good job...
if you wish to share that info it might help others that might have the same problem

nomad
Feb 20 '08 #7
yasmine
65 New Member
I contacted my web hosting company and their is a piece of code they gave me that has to be inserted before the mail( ) function. Wish I knew this before. Thanks for your help ! It is working now.
Hi phpmind,

Could u please send me the piece of code given by the web hosting company?
I'm also having the same problem.......
Plz... help me out....

Thanx n Regards
Yas
Feb 21 '08 #8
phpmind
16 New Member
I was told to insert this code right before the mail () function is executed.

Where 'user@domain.com' should be a valid email address associated with the domain name for example (postmaster@mysite.com)

//initialize mail function for web host
<? ini_set('sendmail_from', 'user@domain.com' ); ?>

Hope this helps!
Feb 21 '08 #9
yasmine
65 New Member
I was told to insert this code right before the mail () function is executed.

Where 'user@domain.com' should be a valid email address associated with the domain name for example (postmaster@mysite.com)

//initialize mail function for web host
<? ini_set('sendmail_from', 'user@domain.com' ); ?>

Hope this helps!

Hi,
Thanx 4 ur reply.

But i'm not sure where to put this code.
Where it should be present whether 'sendfeedback.php' or 'feedback.html'?
What is meant by 'sendmail_from'?

I put it in sendfeedback.php, but the same thing is happened again.(I got the message "Mail Failed" as output.)

Could you please explain...??

Thanx n Regards
Yas
Feb 22 '08 #10
Markus
6,050 Recognized Expert Expert
Hi,
Thanx 4 ur reply.

But i'm not sure where to put this code.
Where it should be present whether 'sendfeedback.php' or 'feedback.html'?
What is meant by 'sendmail_from'?

I put it in sendfeedback.php, but the same thing is happened again.(I got the message "Mail Failed" as output.)

Could you please explain...??

Thanx n Regards
Yas
This is because it's relative to only the OP's (original poster) server.

You might not be running the same PHP.
Feb 22 '08 #11
phpmind
16 New Member
This code would go directly before your mail() function. As the last post states it may be different for your web server/php environment. If you continue to have problem I would suggest contacting your service provider if all else fails.
Feb 22 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Chuck Anderson | last post by:
Can anyone point me in the right direction? I want to use Php to automate confirmation of someone joining an email list by them replying to an email (so they don't have to have a browser?). I...
7
by: BenignVanilla | last post by:
My ISP provides a web based email client, but it is not brandable and the features are not that extensive. I'd like to build my own. Has anyone done this, or is anyone aware of any tools out there...
8
by: JayB | last post by:
We sent out an email today to a list of subscribers from our database using ASP and CDO. For some reason, many people received it twice, including myself. I checked the database and there were do...
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
9
by: Bob Jones | last post by:
We have developed a commercial ASP.net application (personal nutrition management and tracking); we want to send smtp email from within it. For our development box, we use WinXP Pro, IIS 5.5,...
3
by: Frank | last post by:
I am attempting to develop a solution where I handle bounced e-mails. I wish to field all bounced emails in a custom email account such a bounced@mycompany.com From the aricle at...
9
by: Mahernoz | last post by:
Can i send an email from JavaScript? Is it possible? If yes please the code to send email using javascript...
4
Frinavale
by: Frinavale | last post by:
Introduction Many .NET applications will require an email be sent out for various reasons. This article will give a quick examples on how to send an email using VB.NET. The examples given can...
3
by: anu b | last post by:
Hii I am using System.net.mail for sending email... i need to send a webpage with its html content as my email body .....for that i used mail.Isbodyhtml as true...but it is not working for me...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.