colap Posted November 2, 2011 Share Posted November 2, 2011 <?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 ? Quote Link to comment Share on other sites More sharing options...
ocpaul20 Posted November 2, 2011 Share Posted November 2, 2011 in php.ini there are details about smtp server you are using. Have you set these? I think it starts at [mail function] Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 Of course you have to configure it, it doesn't configure itself. Have you got a domain name? Quote Link to comment Share on other sites More sharing options...
colap Posted November 2, 2011 Author Share Posted November 2, 2011 It's localhost. So the from email address will be 'no-reply@localhost.com' . Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 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. Quote Link to comment Share on other sites More sharing options...
colap Posted November 2, 2011 Author Share Posted November 2, 2011 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" . Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 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. Quote Link to comment Share on other sites More sharing options...
colap Posted November 2, 2011 Author Share Posted November 2, 2011 How can i configure sendmail to send email using php function ? Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 Again, do you have a domain? Quote Link to comment Share on other sites More sharing options...
colap Posted November 2, 2011 Author Share Posted November 2, 2011 Again, do you have a domain? I don't have any domain with this local pc. But i have bought a domain for my website. Yes, in that case i have a domain. Quote Link to comment Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 You need a domain pointing to the same server the mail server is running on. If you just need this setup for testing I have already explained an easier option. Quote Link to comment Share on other sites More sharing options...
colap Posted November 3, 2011 Author Share Posted November 3, 2011 The domain i bought has mail server running there. Quote Link to comment Share on other sites More sharing options...
trq Posted November 3, 2011 Share Posted November 3, 2011 Then use ssmtp to connect to (and use) that same mail server for testing. Quote Link to comment Share on other sites More sharing options...
colap Posted November 3, 2011 Author Share Posted November 3, 2011 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' Quote Link to comment Share on other sites More sharing options...
trq Posted November 3, 2011 Share Posted November 3, 2011 I never mentioned anything about sending mail to gmail only. I said, you could use gmail as your mail server if you wished. Quote Link to comment Share on other sites More sharing options...
colap Posted November 4, 2011 Author Share Posted November 4, 2011 I never mentioned anything about sending mail to gmail only. I said, you could use gmail as your mail server if you wished. No, the from address won't be 'abc@gmail.com' rather it would be 'no-reply@domain-of-mailserver.com' Quote Link to comment Share on other sites More sharing options...
trq Posted November 4, 2011 Share Posted November 4, 2011 You can use your own domain with Gmail. Quote Link to comment Share on other sites More sharing options...
colap Posted November 5, 2011 Author Share Posted November 5, 2011 You can use your own domain with Gmail. What do you mean ? Please elaborate . Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2011 Share Posted November 6, 2011 I mean exactly what I said. You can use your own domain with Gmail. http://www.google.com/apps/intl/en/group/index.html Quote Link to comment Share on other sites More sharing options...
colap Posted November 6, 2011 Author Share Posted November 6, 2011 I mean exactly what I said. You can use your own domain with Gmail. http://www.google.com/apps/intl/en/group/index.html Still confusion. What will be the 'from' address to send email ? Do i have to use the gmail address to send the email ? Please elaborate/explain with example . Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2011 Share Posted November 6, 2011 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. Quote Link to comment Share on other sites More sharing options...
colap Posted November 6, 2011 Author Share Posted November 6, 2011 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 ? Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2011 Share Posted November 6, 2011 Most of the time I use Gmails because it's simpler and there is less to have to worry about. Occasionally though I will use Postfix. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.