Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending e-mail via PHP, on behalf of someone else

I would like to create a form that allows users to contact our local city council. I want to make it easy, so they can just fill out the form and send it. I am just not 100% sure how this would work in regards to spam filtering.

  1. I know how to send e-mail through php usind sendmail, and also via Google Apps smtp server.

  2. Mail from our domain has both SPF and DKIM applied, and it is working correctly

What I'm wondering is if someone fills out the form and we use their e-mail address in the from field will it be blocked as spam?

I am not sure how the verification that we have set up to verify mail from our domain will affect mail sent from our server, with a from address that has a different domain.

Any ideas?

like image 341
Sherwin Flight Avatar asked Nov 20 '11 19:11

Sherwin Flight


People also ask

Can we send email through PHP script?

Using the PHP mail() function. PHP's built-in mail() function is one of the simplest ways to send emails directly from the web server itself. It just takes three mandatory parameters: the email address, email subject and message body—and sends it to the recipient.

Can we send mail from localhost in PHP?

The PHPMailer library provides the easiest way to send an email from localhost with an SMTP server using PHP. Not only the text email, but you can also send HTML email from localhost in PHP using PHPMailer.

Does PHP mail need SMTP?

Simple Transmission Protocol (SMTP) ini file. But this will only work for localhost or XAMPP like solutions because as we have already mentioned, PHP mail() function does not support SMTP authentication and doesn't allow sending messages via external servers.


1 Answers

It will most likely be treated as spam as your local mailserver will not feel responsible for sending mail from a domain it does not serve. You can however use a default from address (like [email protected] - just use some domain your mailserver is responsible for) and use the reply-to field for the email address of your user.

like image 193
halfdan Avatar answered Sep 26 '22 05:09

halfdan