Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I cant receive emails sent from the php script

Posted on 2006-11-15
13
Medium Priority
?
233 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 1000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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
 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

926 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