0

I tryied to send an email with php but when i check my inbox there is no email. Even in spam. I used this method couple times before and it worked. Now i don't know what's happening.

mail.php :

include 'include.php';

$subject = 'adamszokalski.pl - Your account is active!';
$message = '<html><body>';
$message .= '<h1> Dear Adam, </h1>';
$message .= 'thank you for registering on our website. We hope you will have good time on it. :) <br/>';
$message .= 'Your payment has arrived and <b>your acconunt has been set activated!</b>';
$message .= 'From now on you have full access to the forum. You can log in <a href="http://adamszokalski.pl/login.php">HERE</a> <br/>'; 
$message .= '<p align="right"> Have nice day! </p> <br/>';
$message .= '<p align="right"><i>adamszokalski.pl</i> </p>';
$message .= '</body> </html>';


SendEmail($sender, $name, 'szokalskiadam@gmail.com', $subject, $message, 'html');

include.php:

$sender = 'no-reply@adamszokalski.pl';
$name = 'No-Reply adamszokalski.pl';


function SendEmail ($ifrom, $iname, $ito, $isub, $imessage, $type) 
{
   $to = $ito;
   $subject = $isub;
   $message = $imessage;
   $headers = 'From: '.$ifrom. '\r\n' .
   $headers .= 'Reply-To: '.$iname.' <'.$ifrom.'>\r\n'; 
   $headers .= 'Return-Path: '.$iname.' <'.$ifrom.'>\r\n';
   $headers .= 'Organization: '.$iname.'\r\n';
   $headers .= 'MIME-Version: 1.0\r\n';
   $headers .= 'Content-type: text/'.$type.'; charset=iso-8859-1\r\n';
   $headers .= 'X-Priority: 1\r\n';
   $headers .= 'X-Mailer: PHP'. phpversion() .'\r\n';
   mail($to, $subject, $message, $headers);
}

I made research on the internet and i still cant solve the problem. Please help! P.S How to use SMTP server to prevent my messages ending up in spam?

EDIT I made an email account on different service (i was on gmail) now i have an O2 account. O2 recives an email but it doesnt display it properly. As you see this email is written in html. O2 displays all the tags and it has problem with dispaying headers properly. How to fix it and why it happens. EDIT 2 How to prevent my messages ending up in spam in Gmail?

A. Szokalski
  • 65
  • 1
  • 6

1 Answers1

1

You should return any value when you call a function.

try this code -

function SendEmail ($ifrom, $iname, $ito, $isub, $imessage, $type) 
{
   $to = $ito;
   $subject = $isub;
   $message = $imessage;
   $headers = 'From: '.$ifrom. '\r\n' .
   $headers .= 'Reply-To: '.$iname.' <'.$ifrom.'>\r\n'; 
   $headers .= 'Return-Path: '.$iname.' <'.$ifrom.'>\r\n';
   $headers .= 'Organization: '.$iname.'\r\n';
   $headers .= 'MIME-Version: 1.0\r\n';
   $headers .= 'Content-type: text/'.$type.'; charset=iso-8859-1\r\n';
   $headers .= 'X-Priority: 1\r\n';
   $headers .= 'X-Mailer: PHP'. phpversion() .'\r\n';
  return  mail($to, $subject, $message, $headers);
}
Sunil Rajput
  • 960
  • 9
  • 19