Jump to content

How to send an email from php5


Recommended Posts

I am new to Php and I am using php5 with apache.


I wanted to have a code which can send an email automatically from the system.. I have the below code with me...


$to = "abcde@in.com";

$subject = "Test mail";

$message = "Hello! This is a simple email message.";

$from = 'From: .'."test".' <xxxxx@in.com>';

$headers = "From: $from";



Can anyone advise me on this as I am not able to send eny email with this.

Link to comment
Share on other sites

$subject='This is a subject string';
$message='This is the body'."\n\n".'On multiple lines';
$headers='From: Your Name <your@email.net>'."\r\n";
$headers.='Reply-To: Your Name <your@email.net>'."\r\n";
$headers.='Reply-Path: Your Name <your@email.net>'."\r\n";
if (mail($to,$subject,$message,$headers)) {
  echo 'Sent.';
} else {
  echgo 'Failed.';


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.