Jump to content

Emails marked as spam by Gmail


Recommended Posts


I have a Processwire site that was made some years ago, and I got a complaint that the emails originating from it, ended up in Gmail's spam folder. I updated Processwire to 2.8, and changed the PHP mail() function I used before, to the newer $mail helper. In the beginning I used a Gmail email for the recipient, but later changed to an info@site.com type, thinking that this could be the problem. Still, the emails are marked as spam.

I used the following code (simplified):

$name = $input->post['name'];
$emailFrom = $input->post['email'];
$message = $input->post['message'];

$form = array(
    'name' => $sanitizer->text($name),
    'email' => $sanitizer->email($emailFrom),
    'message' => $sanitizer->textarea($message),

$message = "Name: $form[name]\n" . 
         "Email: $form[email]\n" . 
         "Message: $form[message]";
$email = $mail->new();


Should I use email header parameters? I can't find what to do in the docs.


Link to comment
Share on other sites

For a complete documentations of $mail take a look here: https://processwire.com/api/ref/wire-mail/

8 minutes ago, alexpi said:

, and changed the PHP mail() function I used before, to the newer $mail helper.

$mail does also use mail() internally if you don't use any 3rd party WireMail module. I'd suggest you to install one of them to not send your emails from php directly. If you still get spam flags then you should look into email domain verifications like SPF or DKIM and maybe use one of those email testing services to analyse your sent mails for other spam triggers.

  • Like 4
Link to comment
Share on other sites

I used the WireMailSMPT module, signed up to an SMTP service (Mailjet), got SPF and DKIM authentications but the service prompts me to validate every email I receive!

I am not sure if I am using $mail correctly, the docs are a little sparse. Do I need to add additional headers or something else?


Link to comment
Share on other sites

$m = $mail->new();
$m->header('Reply-To', $emailBackTo);

Like I said in the WireMailSMTP modules topic: If you use such a service do not send emails with a "From" address, which is not your own. 

Link to comment
Share on other sites

5 minutes ago, LostKobrakai said:

$m = $mail->new();
$m->header('Reply-To', $emailBackTo);

Like I said in the WireMailSMTP modules topic: If you use such a service do not send emails with a "From" address, which is not your own. 

Thanks LostKobrakai, It makes sense now, and it works as expected!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By ngrmm
      I have a page which sends out an email based on queries in the url
      <?php // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $adminEmail = "events@test.com"; $fromEmail = "noreply@test.com"; $fromName = "test"; $emailSubject = "Test Email"; // HTML BODY $emailBody = ""; // HOW TO ??? … // send mail $m = new WireMail(); $m->to($adminEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); ?> The email body is a bit complex: standard html/css tables and some php (pw variables).
      I put my emailbody (html) in a seperate file emailbody.inc but don't know how to include it?
    • By Noel Boss
      To create a new gitlab issue, I'd like to send an Email to the following email address using FormBuilder: 
      unfortunately, the / in the email gets striped by the sanitizer:
      wire('sanitizer')->email(incoming+account/repository@incoming.gitlab.com'); // output: incoming+accountrepository@incoming.gitlab.com Is there any way to configure the sanitizer? Any other Ideas how to send the mail to this address?
      Ps.: I can not define the email format as it is defined by gitlab. The format is also kind of "common" and known as email-alias in the form of emailaccount+alias@domain.com – gmail uses it to label mails…
    • By ihathome
      I'm an abolute newbie in processwire an it's modules. But I have read huge amounts of posts in this forum and as many docs and i learnt a lot in the last days. For a contact-form i used this great module (many thanks) and i hooked it my first time. Everything is alright. Now i search for a possibility to format or render the output in the email. Is there any posibility?
      Thank you for your replies
    • By Kiwi Chris
      Forms are an essential part of most websites, and it's no surprise that there's an excellent premium module Form Builder but what if you're on a zero budget for whatever reason?
      It is possible to build forms quickly and easily by making use of a couple of free modules and the admin UI to give you a great deal of flexibility and speed of development, particularly if you need multiple forms on a website with different fields.
      1. First you're going to need to install a couple of modules:
      Form Template Processor
      Fieldtype Select External Option
      2. For each form that you want to display, create a template without a template file and add fields to it as you normally would. (eg I have formContact, formRegister etc)
      Tip: under the Advanced tab in the setup for each template, I add a tag Forms so that all my forms templates are nicely grouped together in admin.
      3. Create a new field of type Select External Option and call it formTemplate
      In the section Create options from any database table select
      templates as the source table id as the Option Value name as the Option Label 4. Create a new template file and call it renderForm.php (or whatever else you like)
      Add an email field to this form - This will be the email address that forms get submitted to. Add the formTemplate field you previously created to this form. This will allow you to select which of the templates you previously created such as formContact, formRegister etc you want to render. Add any other fields as usual that you want to render on the page. Add the following PHP code to the template file. $recipient = $page->email; $form = $modules->get('FormTemplateProcessor'); $form->template = $templates->get($page->formTemplate->label); // required $form->requiredFields = array('contactName', 'contactEmail', 'contactMesssage'); //Optional: This can be improved by having a field in the page template with a CSV list of required fields eg $form->requiredFields = explode(',', $page->requiredFields) $form->email = $recipient; // optional, sends form as email. FormTemplateProcessor can also save forms to the database. $content .= $form->render(); //generate the form to display. Note: this doesn't actually render the form at this point, but you have it in the $content variable ready to output wherever you want in your template.
      Add any template HTML or other PHP code and echo $content; wherever you want to render the form.
      5. Create a page using the renderForm template, and provide an email address, and select a form that you want to display.
      6. Use CSS to style the form as required.
      7. View your new page, and check that the form renders correctly.
      8. You can modify the templates you created at step 2 or create new ones as required if your requirements for what fields forms display changes.
      Note: The Form Template Processor module can also save form input as pages, and the FieldType Select External Option can be set up with filtering, so this solution can probably be refined further.
    • By henri
      Hi Guys,
      i am a newbe to processwire. Have to maintain a website, but never worked with processwire. I have got an form that is submitted ( i do not have the form thing), to two email addresses. The last week the mails to the second address aren't delivered so it seems. Where do i find the email addresses where the form is submitted to?? I cant find them, though i can find the include of the form. Who knows?????
  • Create New...