Php emails

I am using the standard email code to send an email
mail($to, $subject, $body)

However, for most people who receive this email, the email goes into their junk folder or the hyperlink isnt hyperlinked. Is there anything in php i can do to resolve this?


implied. Given that it’s a php example one can assume that the code would be wrapped in a php tag.

Sorry, I am a bit dumb here. So does that mean the class it requires once will be wrapping everything in php tags?

require_once is a php “function”, not technically, there for it should be in <?php tags as well.

What I said was, they gave you an example of PHP code. They assumed you’d realize it was PHP code and that you would understand that php code should be placed between opening and closing PHP tags. Nothing is magically putting the tags in, you are putting them in by typing them in.

I had that same problem but found when I included headers in the mail() function I had a better success rate… not 100%, but better.

I have actually looked into using PHPMailer. I have a question. On the example code they provide, it looks like

$mail             = new PHPMailer(); // defaults to using php "mail()"
$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\\]",'',$body);

Why dont they put their code in <?php tags?

You could use a service like sendgrid to send email instead of using the mail() function in php. Sendgrid will do a good job of improving your deliverability.