email - Sending E-Mail in PHP -


i tried everything. want send e-mail.

my first code:

<?php $to = "yourgmail@gmail.com"; $subject = "hello"; $body = "hi!"; try {     mail($to, $subject, $body); } catch (exception $e) {     echo 'caught exception: ',  $e->getmessage(), "\n"; } ?> 

it isn't working. no error message, not working.

my second code:

function send_mail('mygmail@gmail.com','yourgmail@gmail.com','hello','hi!') {     $headers = '';     $headers .= "from: $from\n";     $headers .= "reply-to: $from\n";     $headers .= "return-path: $from\n";     $headers .= "message-id: <" . md5(uniqid(time())) . "@" . $_server['server_name'] . ">\n";     $headers .= "mime-version: 1.0\n";     $headers .= "date: " . date('r', time()) . "\n";      mail($to,$subject,$body,$headers); } 

it isn't working too.

please me :)

does work?

first part:

<?php   $to = "yourgmail@gmail.com";  $subject = "hello";  $body = "hi!";  $from = "mygmail@gmail.com";  send_mail($to,$from,$subject,$body);  ?> 

second part:

<?php  function send_mail($to,$from,$subject,$body) {     $headers = '';    $headers .= "from: $from\n";    $headers .= "reply-to: $from\n";    $headers .= "return-path: $from\n";    $headers .= "message-id: <" . md5(uniqid(time())) . "@" . $_server['server_name'] . ">\n";    $headers .= "mime-version: 1.0\n"; $headers .= "date: " . date('r', time()) . "\n";    mail($to,$subject,$body,$headers);  }  ?> 

i'm not sure if can send mail via gmail using php mail function, never looked it, should work name@yourdomain.com


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -