views:

203

answers:

2

I wrote php code for use to contact us form

but I can not find free SMTP server to use it.

I Try to use SMTP Server For Gmail but I found this error.

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\www\htdocs\contactUs.php on line 25"

line 25 is :

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

statement that indicate using Gmail SMTP Server is :

ini_set("SMTP","smtp.gmail.com");

SO,can U help me ?:(

A: 

Sorry , can you tell me how ? :) I set it in php code between php tags!! –

Nuha
A: 

You need a From: [VALID EMAIL] header of the message when you send the message. Try doing something like this:

$headers = array(
    'From: [email protected]',
    'Mime-Type: text/plain; charset=utf-8',
);

$dest = '[email protected]';
$subj = 'test';

$message = 'hello world';

mail($dest, $subj, $message, implode("\r\n", $headers));

Also, the mail function is meant to be used as a frontend to the mail daemon that's running on the same server the web server is running on. Since most *NIX boxes have both, it usually works.

What I would not recommend, however, is using some remote server to send your mail. It's much more efficient and reliable (not to mention looking more professional) to just have the same server send the message as the one that generated the message.

Setting up your own SMTP server is easy and free and more flexible than Gmail. Gmail WILL NOT send messages whose From: header does not match either the main account address or a connected address.

amphetamachine