Hi Chaps, I've been searching on Google for ages now and can't seem to find a solution that works. I have a mail script: $to = 'someone@somewhere.com'; $subject = "You've got Mail!"; $message = 'This is a test Email'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Webmaster <do-not-reply@domain.com>' . "\r\n"; $sent = mail("$to", "$subject", "$message", "$headers") ; PHP: This code is tried and tested on a UNIX server and sends to Hotmail accounts. However, I had to change this: to this: to even get mail() to work on my work IIS server, but it doesn't send to Hotmail accounts. I thought that Hotmail may have blacklisted our work DNS settings, but I can send emails from my work email account to Hotmail account without any problems and IIS and MS Exchange on the same server. . . . . Is there something else I can try or look for as this is doing my nut in?
$to = 'someone@somewhere.com'; $subject = "You've got Mail!"; $message = 'This is a test Email'; $fromemail = 'do-not-reply@domain.com'; $headers = "From: ". preg_replace('/[\r\n\t\s:]/', null, $fromemail); $headers .= "\nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\n"; $sent = mail("$to", "$subject", "$message", "$headers") ;
Emails sent via php mail() function will always sent to junk folders of hotmail, yahoo and gmail as your IPs are not trusted. However, if you really wish to send email in user inbox, you should use SMTP function to send email istead php mail funciton. SMTP function will send email after authentication and it will always sent to inbox. This is my own experience. Might be someone else have different experience. You should try it. I have pasted sample php code here. <?php require_once "Mail.php"; $from = "Sandra Sender <sender@example.com>"; $to = "Ramona Recipient <recipient@example.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "mail.example.com"; $username = "smtp_username"; $password = "smtp_password"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?>
I recommend using the phpmailer class, very efficient for maintaining same mail code on diff servers.