Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I cant receive emails sent from the php script

Posted on 2006-11-15
13
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 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