Jump to content

How to send mail


lhbdan

Recommended Posts

The mail function can only work if you have told PHP which mail server to use to send the mail out.

 

If you are in control of your server, you need to set the smtp server in your php.ini file.  If you are on shared hosting, then they should be able to set this up for you.

Link to comment
Share on other sites

I think this is what i'm using at work for production equipment to send status info.

 

In php.ini do the following:

[mail function]

; For Win32 only.

SMTP = mail.subdomain.domain.org    <<<----  fix this line, get it from your email program

smtp_port = 25

 

 

 

; For Win32 only.

sendmail_from = UserOnMyComputer@domain.com    <<<- fix the sent from address.

 

 

 

 

 

Restart Apache.

 

 

 

 

 

Here’s the php code.

<?php

$to = "someone@gmail.com";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";

if (mail($to, $subject, $body)) {

  echo("<p>Message successfully sent!</p>");

} else {

  echo("<p>Message delivery failed...</p>");

}

?>

 

 

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.

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.