943,881 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3797
  • PHP RSS
May 2nd, 2007
0

Generate Email script

Expand Post »
How can i make this script work?
It is meant to send an email to a person with a confirmation code, but it is not working. whats wrong with it?

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. function send_mail($fromname,$frommail,$to,$subject,$body,$priority)
  4. {
  5. $fullmail = "\"$fromname\"<$frommail>";
  6. $headers = "From: $fullmail\n";
  7. $headers .= "X-Sender: $fullmail\n";
  8. $headers .= "X-Mailer: PHP\n";
  9. $headers .= "X-Priority: $priority\n";
  10. $headers .= "Return-path: $fullmail\n";
  11.  
  12. mail($to,$subject,$body,$headers);
  13. }
  14.  
  15. function send_html_mail($fromname,$frommail,$to,$subject,$body,$priority)
  16. {
  17. $fullmail = "\"$fromname\"<$frommail>";
  18. $headers = 'MIME-Version: 1.0' . "\n";
  19. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
  20. $headers .= "From: $fullmail\n";
  21. $headers .= "X-Sender: $fullmail\n";
  22. $headers .= "X-Mailer: PHP\n";
  23. $headers .= "X-Priority: $priority\n";
  24. $headers .= "Return-path: $fullmail\n";
  25.  
  26. mail($to,$subject,$body,$headers);
  27. }
  28.  
  29. ?>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tomf is offline Offline
9 posts
since Apr 2007
May 2nd, 2007
0

Re: Generate Email script

What kind of error are you getting? The odds are the problem lies somewhere else in the code.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
May 2nd, 2007
0

Re: Generate Email script

We can't debug unless we know what the problem is The format for the output should be headers, then a single blank line, and then the message.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
May 2nd, 2007
0

Re: Generate Email script

Well, its just not sending the email at all!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tomf is offline Offline
9 posts
since Apr 2007
May 2nd, 2007
0

Re: Generate Email script

You'll need to echo out some variables in your script to make sure you have the right information there and to make sure you are getting there at all.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
May 3rd, 2007
0

Re: Generate Email script

What OS is your server on?

Windows requires an SMTP server.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
May 3rd, 2007
0

Re: Generate Email script

Its clustered linux servers i think
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tomf is offline Offline
9 posts
since Apr 2007
May 3rd, 2007
0

Re: Generate Email script

Click to Expand / Collapse  Quote originally posted by tomf ...
Its clustered linux servers i think
Check first with your hosting company support and see if they have mail() set up properly. If they either you have a problem with your code or your mail may be blocked or added to spam.

You'll need to place some debugging into your code.

for starters:

[PHP]if (!mail(....)) {
echo 'Mail is not working... ';
}[/PHP]

mail() will return Boolean true or false if working or not respectively.

Set your error reporting to max:

[PHP]error_reporting(E_ALL);

ini_set('display_errors', 'true'); // not sure bout this one, I think thats the correct config option[/PHP]

Just try a simple mail() first.. don't use the abstraction function "send_mail".. just to test if its working.

Check if your hosting company's mail servers are not blacklisted.
Send emails to a few different addresses to make sure its not specific to an email address...
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Getting Info. for specific record?
Next Thread in PHP Forum Timeline: Upload file without User Interaction





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC