0

I have a VPS which is running on Ubuntu 14.04. Apache, MySQL and PHP are installed and working fine.

The server is used to host a website, which has a contact form. The contact form is getting some variables from the users such as their email, subject and body (using POST). This message is then processed using PHP's standard mail() function.

Well, this was working fine on my old hosting provider, but not anymore in this "self-made" server.

I tried configuring Sendmail and adding its path to php.ini, whithout any success. I've also tried using the library PHPMailer hoping to use an external SMTP server without having to configure a local one. This works fine (PHPMailer is actually great), as long as the sender is the same identity as the user authenticated to the SMTP server... which is never going to happen with such a form where the sender is always someone different.

Something apparently easy is becoming a headache now. The question is... how do I get the form to work, without having to setup any local mail server and without having the limitation to send emails just from one specific email address?

Thanks a lot in advance!

Oleg
  • 654
  • 1
  • 7
  • 16
  • so um install a mail server –  Feb 03 '16 at 00:52
  • You should never use the form submitter as the sender or from address. It will just cause SPF failures. Use your own address as the from address and put the submitter's address in reply-to. – Synchro Feb 03 '16 at 07:13
  • @Synchro Thanks a lot for the info! I thought the form submitter's email should go as "$mail->setFrom". This can actually be the solution I was looking for for such a long time. – Oleg Feb 03 '16 at 11:24
  • @Synchro it worked fine and solved my problem. Thanks again. – Oleg Feb 03 '16 at 14:28

1 Answers1

0

Stupid question, but does your VPS provider give you a dedicated SMTP server you can use PHPMailer (and others) with? For example, I use SiteHost here in New Zealand and they permit their VPS users to utilise their internal SMTP server. I'd be surprised if folks such as DigitalOcean (and whoever you use) don't have something similar.

FYI I have had the exact same problem (Debian Jessie though not Ubuntu server) in the past with shared VPS I have, I ended up going with Postfix instead. To get it "just running" took surprisingly little effort when installed from apt-get. Just understand the risks inherent in managing your own email-exchange server - which I'm guessing you do, given you've gone down the VPS route :-)

theruss
  • 1,690
  • 1
  • 12
  • 18
  • I am not aware of such a feature in the case of Digital Ocean. I will try to fix my problem using @Synchro 's comment. I will also try to setup Postfix. Thanks for the answer. – Oleg Feb 03 '16 at 11:32