php mail

Status
Not open for further replies.

bamboohead

New Member
Messages
4
Reaction score
0
Points
0
Hi,

I have not gotten my php mail to work. I have checked the spam folder and I have tried snippets of code found in this forum. I have also tried sending to yahoo and gmail. Does anybody know what else could be wrong?

I'm using the free hosting. When I checked the return value of mail command, it returns true.:dunno:
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
you should probably post your code in the programming help forum for better help.

I know there have been some issues with the mail() function, I thought they have been cleared up though.
 

bamboohead

New Member
Messages
4
Reaction score
0
Points
0
I have tried below. Modifying only $contactemail .

Code:
<?php
  $contactemail = "some_one@exa.com";

  $headers  = 'MIME-Version: 1.0' . "\n";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
  $headers .= "Content-Transfer-Encoding: 7bit\n";
  $headers .= 'From: You(som@yahoo.com)' . "\n";
  $headers .= 'Reply-To: you@cossacks.com' . "\n";
  $headers .= 'Return-Path:'.$contactemail . "\n";
  $headers .= 'X-Sender: '.$contactemail. "\n";
  $headers .= 'X-Mailers: PHP /'.phpversion() . "\n";

  $subject = "whatever subject";

  $message  = '
  whatever message
   ';


  ini_set(sendmail_from,$contactemail);

  if (@mail('You <'.$contactemail.'>',stripslashes($subject),stripslashes($messa
ge),stripslashes($headers)))
  {
    echo ('<h1>Sent</h1><p>This email has been successfully sent to ' . $contact
email . '.</p>');
  }
  else
  {
    echo ('<h1>Sorry!</h1><p>Your message has failed to send to ' . $contactemai
l . '. Please try again later.</p>');
  }


  ini_restore( sendmail_from );

?>
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
you have to use \r\n instead of \n

see if that helps
 
Last edited:

bamboohead

New Member
Messages
4
Reaction score
0
Points
0
Thank you.

I wonder how the other folks got it to work when their code didn't have the carriage return character.
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
no idea. \r\n is a standard for sending mail, not just a recommendation :p
 
Status
Not open for further replies.
Top