Solved

I cant receive emails sent from the php script

Posted on 2006-11-15
13
225 Views
Last Modified: 2007-01-02
hi i had a php script installed on my website's contact page but i cant receive emails sent from this php script. althogh i get a message saying information sent successfully on the website but i cant find the email in my mail box anywhere.. my coding of the mail portion is as follows

 if ($send != "no") {
   
        // this is the info that comes on the email when it's ok to send!
        $msg = "E-MAIL SENT FROM http://www.yoursite.net/contact/\n";
        $msg .= "Sender's Name:    $sender_name\n";
        $msg .= "Sender's E-Mail:  $sender_email\n";
          $msg .= "Sender's  Company:  $sender_company\n";
        $msg .= "Message:          $message\n\n";    
       /* $to = "ryulite04@gmail.com";*/
        $subject = "Information";
        $mailheaders = "From: Information\n \n".
                                    "Reply-To: $sender_email\n\n".
                                    'MIME-Version: 1.0' . "\r\n".
                                    'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        mail("ryulite04@gmail.com", $subject, $msg, $mailheaders);
        echo " <div align=\"center\"><table  width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    echo " <tr><td height=\"20\" colspan=2 >&nbsp;</td></tr>";
     
is there anything wrong with the way i wrote the code?
0
Comment
Question by:ryulite
  • 6
  • 4
13 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 250 total points
ID: 17953094
Two things.
1.  You have, in a couple places, \n\n.  That's incorrect.  All headers in e-mail always end with \r\n (it doesn't matter what platform you're using). Inside the body of the message you're free to write anything you like, but in the headers it's always \r\n.

2.  You've got a header that reads "From: Information"  That's not a valida ddress, so I wouldn't expect your server to pass it along.

0
 

Author Comment

by:ryulite
ID: 17953143
so for the header that reads from information.. what would be the best way to write it? is it my own email address or?
0
 

Author Comment

by:ryulite
ID: 17953156
can i put From:Information as From:www.makemoneywithlynn.biz or From: $sender_email
0
 

Author Comment

by:ryulite
ID: 17953180
i tried From: $sender_email but no avail
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953184
The From: is the genuine From: header that will show up on the incoming mail, so it can't be just a domain name, and I'd recommend against using $sender_email for semantic reasons (though that would certainly work).  

If possible, use some account on your e-mail server that can receive mail (even if nobody's ever going to look at it) so you have the option fo doing something like bouncing back messages that come there (in case anybody replies to this e-mail).  As long as it's a legitimate-LOOKING e-mail address (that your server will recognize) you should be fine.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ryulite
ID: 17953212
i used my hotmail address but it still doesnt work.. or they cant accept free based address?
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953224
It's entirely up to how the SMTP server you're using is configured.  I've worked with some systems that blindly send on any address, and others that only accept mail from addresses on that system.  As I said, your best bet is to use an address on that system (i.e. the system that's hosting your SMTP server) that it will recognize as genuine.
0
 

Author Comment

by:ryulite
ID: 17953382
i used my teknon media's web hosting email but i cant get it to send it to my email account.
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953399
Looking back through this I've realized you never actually said...

Does the mail() function actually return true?
0
 

Author Comment

by:ryulite
ID: 17953466
ssorry but i am a newbie to php and i don really know how to run through the code with dreamweaver
0
 
LVL 1

Assisted Solution

by:saukstas
saukstas earned 250 total points
ID: 17954003
If you want to check do this:
 $sent = mail(<everything you wrote there>)

if ($sent) {
 echo "sent ok";
} else {
 echo "sent failed"
}

your php configuration may not allow you to send emails because of missing SMTP configuration. open your php.ini file and look there for configuration value named smtp. you should write there your ISP's SMTP server's address.

Good luck ;)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now