Jump to content

Is it must to have a mail server installed/configured to send mail with php mail


colap

Recommended Posts

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

 

http://php.net/manual/en/function.mail.php

 

I have installed sendmail, do i have to configure it to send email with php email ?

 

How can i configure sendmail to send mail ?

Link to comment
Share on other sites

You won't be able to send mail to the outside world without a valid domain. You might, but it will just go to trash.

 

If your simply wanting this for testing purposes I would recommend uninstalling sendmail and installing ssmtp. ssmtp will allow you to use a remote mail server such as that provided by your isp or Gmail to send mail. It is a drop in replacement for sendmail.

Link to comment
Share on other sites

You won't be able to send mail to the outside world without a valid domain. You might, but it will just go to trash.

 

If your simply wanting this for testing purposes I would recommend uninstalling sendmail and installing ssmtp. ssmtp will allow you to use a remote mail server such as that provided by your isp or Gmail to send mail. It is a drop in replacement for sendmail.

 

How can i send email from my local pc ?

 

Suppose my local pc hostname has been set to "myhost.com" .

Link to comment
Share on other sites

How can i send email from my local pc ?

 

For it to not go straight to the trash you will need a valid domain.

 

Suppose my local pc hostname has been set to "myhost.com"

 

hostnames and domain names are not the same thing.

Link to comment
Share on other sites

Then use ssmtp to connect to (and use) that same mail server for testing.

 

I don't want to send email to gmail account only.

 

It should send email to any email address .

 

And the from address would be 'no-reply@domain-of-mailserver.com'

Link to comment
Share on other sites

I'm not spoon feeding you. It's simple.

 

Gmail offers the ability to use there servers with your domain. When you send an email, it will come 'from' your domain via gmails mail servers.

So the 'from' address will be 'mypcuseraccount@mypchomedomain.com' , right ? And gmail server will act as a relay, right ?

Which mail server do you use ?

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.