0

I have found loads of topic regarding email not sent but none got me to help. I am running the following code for firing an email from my web server .

$to = "someone1000@gmail.com";
$subject = 'File Report On '.$date; 
$txt = $body;

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

$headers .= "From: suose@hotmail.com" . "\r\n" .
            "CC: rahs1345@gmail.com";

mail($to,$subject,$txt,$headers);

The above code running fine on other servers . Now the web server which i am using for this code is behind a VPN connection and the address is private.

I have tried PHPMailer , i have tried inbuilt mail function, on both the cases i have tried to throw errors but there was no error at all , every time it says email sent. I am just suspecting is it has anything to do with the web server as it is behind a private connection?

Megan Fox
  • 435
  • 2
  • 6
  • 20

2 Answers2

0

Try the following code. There is a small mistake you are not concatenating $header variable.

$to = "rahuldasgpta1000@gmail.com";
$subject = 'File Report On '.$date; 
 $txt = $body;

$headers= "MIME-Version: 1.0" . "\r\n";
$headers.= "Content-type:text/html;charset=UTF-8" . "\r\n";
//See the following line in your code you are missing '.' after $header
//Make sure concatenation is there.
$headers.= "From: surajbose@hotmail.com" . "\r\n" .
        "CC: rahul19832003@gmail.com"; 
Hraday Joshi
  • 159
  • 1
  • 10
0

Check your php.ini file

Add following code in php.ini for mail (using sendmail)

[mail function]
; Setup for Linux systems
sendmail_path = /usr/sbin/sendmail -t
sendmail_from = me@myserver.com

For SMTP Configuration php.ini :

[mail function]
; Setup for Windows systems
SMTP = smtp.my.isp.net
sendmail_from = me@myserver.com