tags:

views:

122

answers:

3

Hello every body How can I send an email using mail function in php. have I to put mailServer IP address in this function

I'm waiting for you reply

Thanks anyway

+1  A: 

Everything you need to know about the Mail() function is described here. That being said, Mail() does not accept mail server configurations. You configure the mail server in your php.ini file (if you don't know where it is located, you should probably contact your system administrator to configure it for you).

Also I would suggest using some PHP mailer class for sending emails. Such as PHP Mailer or SwiftMailer. This classes will save you many troubles with headers, attachments, etc

Jan Hancic
A: 
<?php
$to='[email protected]';
$subject='hi!';
$msg='Test';
mail($to,$subject,$msg);
?>

You can look in the Php manual for details on the additional headers you can supply with the email, to provide the senders name and reply-to email address, etc.

Click Upvote
+4  A: 

PHPMailer is pretty much the defacto drop in mailer class for every day use.

http://phpmailer.codeworxtech.com/

I personall wrote my own: http://neranjara.org/article/title/PHP_Socket_based_Mail_class_with_CRAM-MD5_Authentication

Have fun!

Nathacof