Jump to content

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";

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='some@somewhere.net';
$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.';
}

 

I tried the same and it says "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in "

 

What all do I have to configure in php.ini file ?

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.

Guest
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.