Mail Codes in php.ini

the mail() function

Moderators: macek, egami, gesf

Philosophaie
New php-forum User
New php-forum User
Posts: 4
Joined: Fri Feb 10, 2012 9:30 pm

Mail Codes in php.ini

Postby Philosophaie » Sat Feb 25, 2012 9:27 am

The below code does not send an email to "this@email.com". I think it has to due to the email settings in "php.ini". How do I change these settings so that I can email from PHP.

Code: Select all

<?php
$to = "this@email.com";
$subject = "test Email";
$message = "Just a test to see if it works.";
$from = "that@email.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers)
?>

User avatar
freshnet
php-forum Active User
php-forum Active User
Posts: 285
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: Mail Codes in php.ini

Postby freshnet » Fri Mar 23, 2012 2:51 am

Here's what I use as my headers in one site.

Code: Select all

$headers = "MIME-Version: 1.0" . "\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\n";
$headers .= "From: $from" . "\n";


Do you get any error, if so, what is it? This link may help you as well for configuring things on the ini side. http://php.net/manual/en/mail.configuration.php


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 0 guests