Jump to content

How to send an email from php5


rahul_jjj

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 = "[email protected]";

$subject = "Test mail";

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

$from = 'From: .'."test".' <[email protected]>';

$headers = "From: $from";

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

 

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

Link to comment
https://forums.phpfreaks.com/topic/138164-how-to-send-an-email-from-php5/
Share on other sites

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.