Django can send email from Python Shell but Gmail blocks mail when sent from front end form

I’m trying to make a password reset via email page following the tutorial here:
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Authentication#password_reset_templates

I can send emails while in the Python-Django shell but when I try to send it via that form, Gmail blocks my messages.

I have my email settings in settings.py configured as:

#gmail_send/settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'foo@gmail.com'
EMAIL_HOST_PASSWORD = os.environ('EMAIL_PASSWORD')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER

When I do this using the shell, I’m able to receive the email:

>>> from django.core.mail import send_mail
>>> send_mail('test email', 'hello world', 'your@email.com', ('test@email.com'))

My password reset form looks like this (base_generic just has some bootstrap and jquery CDN stuff along with a navbar)

{% extends "OracleOC/base_generic.html" %}

{% block content %}
  <form action="" method="post">
  {% csrf_token %}

  {% if form.email.errors %}
    {{ form.email.errors }}
  {% endif %}
      <p>Please enter your email:</p>
      <p>{{ form.email }}</p>
    
    <input type="submit" class="btn btn-primary main_menu_button" value="Reset password">
  </form>
{% endblock %}

When I press submit, everything looks fine and I get a

(17/Jan/2021 07:04:12) "GET /accounts/password_reset/done/ HTTP/1.1" 200 2105

in my Django console but I get a copy of the message in my sender gmail box with this message:
Gmail blocked my message!

No authentication error, Insecure Apps setting on.

css – Failed to send HTTP request body

Stack Exchange Network


Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

wifi – Does my wireless adapter support the packet injection if I it can send deauth packets?

So, I want to know a little bit about wifi security and I am interested on some questions. So, I want to know when somebody sends the deauth packets does it mean that the deauth packets are the packet injection proccess? Does my wireless adapter support the packet injection if I it can send deauth packets?

8 – How to send a form back a step in a multistep Webform

I am trying to figure out how to programmatically boot a user back to an earlier step if they fail validation or submission on one of the final steps of a form. The form has to check some remote service calls before accepting the submission.

I tried to add a validate hook and try something simple:

function mymodule_schedule_validate($form, FormStateInterface $form_state) {
  $page = $form_state->get('current_page');

  if ($page == 'step_2') {
    $form_state->setErrorByName('tour_date', 'Pick some other thing or whatever');
    $form_state->set('current_page', 'step_1');
    $form_state->setRebuild();
    #$form_state->setRedirect(new RedirectResponse(DrupalCoreUrl::fromUserInput('/form/schedule')->getRouteName()));
  }
}

While the code is hit when step 2 is submitted, and it sets current page to step_1, nothing else happens. The error appears, but the form displayed in the modal is still step 2. I tried with and without the redirect.

How can I manipulate the form this way?

smtp – Configure postfix to send via IPV4 but receive using both IPV4 & IPV6?

Is it possible to configure postfix to send via IPV4 only but receive using both IPV4 & IPV6?

My server, running on AWS Lightsail, now can have an IPV6 address. The address is relatively static (as long as I keep IPV6 active on the instance), but it’s not truly static because I can’t move the address from server to server (like I can do with the static IPV4 address). I also can’t (currently) as Amazon to assign an PTR record for the IPV6 address.

As I have the IPV6 address available, I’d like to be able to receive mail using either IPV4 or IPV6 but only send using IPV4.

I know I can set postfix to only listen on the IPV4 address using the inet_protocols setting.

php – Mails don’t send on live server but on localhost they work using PHPMailer

I am having a really weird issue which I can’t manage to fix.

The thing is, we had a website hosted in a VPS using Apache, everything was working well. We decided to change the VPS, and I re-installed everything and configured everything exactly like I did on first one.

My problem now is that I have a user registration form that send an activation link, but for some reason it stopped to work on live server.

I am using:

Here is my code:

        //Require PHPMailer class     
        require APP . 'libs/PHPMailer/Exception.php';      
        require APP . 'libs/PHPMailer/PHPMailer.php';
        require APP . 'libs/PHPMailer/SMTP.php';
       
        $mail = new PHPMailerPHPMailerPHPMailer();
        $mail->isSMTP();
        $mail->Host = 'smtp-relay.sendinblue.com';
        $mail->SMTPAuth = true;
        $mail->Username = 'user'; // Sendinblue Username
        $mail->Password = 'pass'; // Sendinblue Password
        $mail->SMTPSecure = 'tls';
        $mail->Port = 587;

        $mail->setFrom('no-reply@example.net', 'Example');
        $mail->addAddress($email); 

        $mail->Subject = 'Example | Account Verification';
        $mail->isHTML(true);
        $mailContent = '            
        Thanks for Joining Example! Please activate your account by clicking on the link below.<br/>

        <a href="https://www.example.net/account/verifyAccount?email='.$email.'&hash='.$hash.'">CLICK HERE</a><br/>
        If you did not sign up for an account please disregard this email.
        ';

        $mail->Body = $mailContent;
        $mail->send();

Do I need to open the port 587 on my VPS? I don’t remember doing this before in the old VPS.

php – Send attachment after form submission to user email and post data to admin

I have a form which on submit must send the data collected to the admin email (i grab it via post), and the user gets a gift – an email with an attachment is sent to him. How can i do this ?

Html code:

<div class="modal">
                            <form id="program-four-modal" method="post" action="makepdf.php">

                                <!-- Hidden Required Fields -->
                                <input type="hidden" name="project_name" value="test.com/offer/">
                                <input type="hidden" name="admin_email" value="info@semseo.md">
                                <input type="hidden" name="form_subject" value="Vreau cadoul - Lorem ipsum">
                                <!-- END Hidden Required Fields -->

                                <h3>Aplic─â</h3>

                                <input type="text" name="NumePrenume" placeholder="Nume Prenume..."
                                    title="Nume Prenume" required><br>
                                <input type="email" name="Email" placeholder="E-mail..." title="E-mail" required><br>
                                <input type="tel" name="NrDeTelefon" placeholder="Nr. de telefon..."
                                    class="checkphone" title="Nr de telefon" required>

                                <div class="program-four-modal-send-wrapper">
                                    <button type="submit" class="program-four-modal-send">Trimite</button>
                                </div>

                            </form>
                        </div>

                        <a href="#program-four-modal" class="btn program-four-btn" role="button" rel="modal:open">I want the gift</a>
                    </div>

Here i grab the variables from the form via post. Currently both user and admin get the same email https://prnt.sc/wmygg2 , https://prnt.sc/wmygpe .

Php code:

<?php

use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerSMTP;
use PHPMailerPHPMailerException;

require_once __DIR__ . '/vendor/autoload.php';

// Grab variables
$subject = $_POST('form_subject');
$name = $_POST('NumePrenume');
$email = $_POST('Email');
$phone = $_POST('NrDeTelefon');

// Create PDF
$data = '';
$data .= '<h1>Your details</h1>';

// Add data
$data .= '<strong>Name</strong> ' . $name . '<br />';
$data .= '<strong>Email</strong> ' . $email . '<br />';
$data .= '<strong>Phone</strong> ' . $phone . '<br />';

    // Instantiation and passing `true` enables exceptions
    $mail = new PHPMailer(true);

    try {
        //Server settings
        $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output
        $mail->isSMTP();                                            // Send using SMTP
        $mail->Host       = 'smtp.hostinger.ru';                    // Set the SMTP server to send through
        $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
        $mail->Username   = 'admin@mustcode.xyz';                     // SMTP username
        $mail->Password   = 'password';                               // SMTP password
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
        $mail->Port       = 587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

        // Recipients
        $mail->setFrom('admin@mustcode.xyz', 'Gift Form');
        $mail->addAddress($email);     // Add a recipient

        // Attachment
        $mail->addAttachment('gift/sample.pdf');

        // Content
        $mail->isHTML(true);                                  // Set email format to HTML
        $mail->Subject = $subject;
        $mail->Body    = $data;
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

        $mail->send();
        echo 'Message has been sent';
    } catch (Exception $e) {
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }

Send form cf7 without form template

I wanna send form with options and I want send all data from page without form template. I have a different message depending on the user’s choice. I use conditional fields.

How I can do this?
hat’s the last thing i have to do

This is options in form, user added new child to form and this will be agreement and template is not good for this, show unnecessary text.

I want do this without template :]

How to send little BTC coin in Bitcoin wallet

I use bitcoin wallet (find here)

I tried to send 32$ (All of them) to Binanace OR my Trust wallet or etc , but appear below error :

enter image description here

Make right-click, “send to mail recipient” send to Gmail via Chrome in Windows 10

I have recently decided to use Windows 10 rather than MacOS as my main OS (for many reasons, which I could go into somewhere else), and find that occasionally I would like to send a file to someone via Gmail. I would like to be able to right-click on a file in Windows Explorer, select “Send to”, then “Mail recipient” and have a Gmail compose window open in Chrome with the file already attached. Is there any way to do this?

I have tried setting Chrome to be the default email handler, and in Chrome, setting Gmail to be the default email client; and I have also tried setting Windows Mail to be the default mail handler, and adding my Gmail account to Mail, but in both cases, when I right-click on a file, send to, mail recipient, I get a popup:

There is no email program associated to perform the requested action. Please install an email program or, if one is already installed, create an association in the Default Programs control panel.

I really do not want to use a client like Outlook or Thunderbird which, from past experience, will insist on downloading literally hundreds of thousands of message headers (I am not even attempting to be inbox-zero!), I just want to send a file quickly without having to open Gmail in Chrome, create a new message, click Attach, find the file, attach it. I want a way of doing all that automatically from Explorer. Any ideas?