# Handing over eMails from POST to standard Mail-App

**URL:** <https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185>\
**Category:** Forms & APIs\
**Created:** [April 11, 2023, 5:36pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185 "2023-04-11T17:36:33Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 11, 2023, 5:36pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/1 "2023-04-11T17:36:33Z")

</div>

Hi folks,

im still new to Django and battling everyday with different things. My Question today:  
Let’s say, i have a template with a list of People including their eMail-Adresses. Let’s say, i have put some checkboxes to the eMail adresses and included a Button to the site which says “send Mail to all checked adresses”.

AND let’s say, that this after all WORKS (i get the checked adresses flawlessly written in console when using “print(request.POST)”…so the template is posting the desired informations. But what next?

I would like to set up a procedure in the view under the

if request.mehod == ‘POST’

where all posted mail adresses are forwarded to the standard mail program of the used OS…and in best case they are insertet not in normal recipient field but to BlindCopy (on behalf of some data security regulations)…

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 11, 2023, 5:45pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/2 "2023-04-11T17:45:09Z")

</div>

For sending email, see [Sending email | Django documentation | Django](https://docs.djangoproject.com/en/4.1/topics/email/)

However, you wrote:

> [@doc1977](#):
>
> are forwarded to the standard mail program of the used OS

First, there is no such thing as a “standard mail program”.

Second, you don’t send mail through the user’s email client - you send emails out through an email server, usually through SMTP. How the user retrieves those emails is up to them.

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 11, 2023, 6:01pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/3 "2023-04-11T18:01:35Z")

</div>

Ok, maybe we are talking about different things. Of course, there is a standard mail programm of an os. It has to be set up within the os configuration, that is true but what i am talking about is: When i am clicking on a marked href:“mailto” link, on my PC, Microsoft Outlook pops-up and offers me the opportunity to send a mail to this contact i have clicked seconds ago…

Hope that helps to clarify

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 11, 2023, 6:12pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/4 "2023-04-11T18:12:48Z")

</div>

Means: I dont want to sent eMails via DJANGO itself, i just want to know how to make django hand over several email-addresses to the standard mail programm of used os. As it works with “mailto” entries on template.  
In best case, for mail to many recipients, data should be passed to the BCC Field of Mail-App 😉

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 11, 2023, 6:27pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/5 "2023-04-11T18:27:53Z")

</div>

> [@doc1977](#):
>
> Of course, there is a standard mail program of an os.

No, there isn’t.

There might be a default selected when an OS is configured for use, but there is no _standard_. Microsoft Outlook is not the “standard”, it is one option among many. The best you can say is that it’s the **default** for that particular user.

However, that still doesn’t mean that the browser is going to open _that_ application when a `mailto` link is clicked. That is something that may be configured within the browser itself. (For example, see the `Applications` options in the `General` section of the `settings` within Firefox.)

As a result, there is no “guaranteed-to-work” method for opening up the email client from a browser and ensuring that certain fields are filled out.

See

- [Creating hyperlinks - Learn web development | MDN](https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Creating_hyperlinks#email_links),
- [\<a\>: The Anchor element - HTML: HyperText Markup Language | MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#linking_to_an_email_address),  
and
- [RFC 6068 - The 'mailto' URI Scheme](https://datatracker.ietf.org/doc/html/rfc6068)

for more details.

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 11, 2023, 6:44pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/6 "2023-04-11T18:44:51Z")

</div>

Seriously? We are text-battling about “standard” and “default” besides the fact that you meanwhile surely know what i am talking about ? I am no native english speaker.

Thanks for the references, but references to this topic i got a lot before posting here. Posting references is no (or in rare cases) help for a specific question but only a tool for raising own post-counts…

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 11, 2023, 7:03pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/7 "2023-04-11T19:03:25Z")

</div>

> [@doc1977](#):
>
> I am no native english speaker.

I am impressed. I give you great credit for your education - that certainly hasn’t been evident from the written quality of your posts. And your English is far superior than my knowledge of whatever your native language may be.

Going back to the earlier posts:

> [@doc1977](#):
>
> When i am clicking on a marked href:“mailto” link, on my PC, Microsoft Outlook pops-up and offers me the opportunity to send a mail to this contact i have clicked seconds ago…

Those links give you the specifics of how you can create a link in a page to open up whatever email client the user has configured in their browser, and (potentially) supply information for that email.

Beyond that, no, I’m not sure what you’re asking for at this point.

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 13, 2023, 9:10am UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/8 "2023-04-13T09:10:07Z")

</div>

First: I’m sorry about my rough reply last time. was tired and annoyed due to some things the kids had done 😛 So take this please for an apology, because i know that nobody HAS to spend time here answering questions. I appreciate your support. Will read your posted links again carefully and if afterwards something should be still troubling me, i will post here again.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 13, 2023, 12:04pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/9 "2023-04-13T12:04:39Z")

</div>

No worries, I understand how frustrating this can be - especially when working in your non-native language. I think if we can get to a common understanding of what you’re trying to accomplish here, we’ll get answers.

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 17, 2023, 7:02pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/10 "2023-04-17T19:02:23Z")

</div>

so i have read your links and some others and i solved my problem, what i wanted to do was simply something like this 🙂

```auto
{% if priv_mails %}
    {% if comp_mails != None %}
        <meta http-equiv="refresh" content="0;url=
        mailto:{% for comp_mail in comp_mails %}{{ comp_mail }}{% if not forloop.last %},%20{% endif %}{% endfor %}
        ?bcc={% for priv_mail in priv_mails %}{{ priv_mail }}{% if not forloop.last %},%20{% endif %}{% endfor %}" />

     {% else %}
        <meta http-equiv="refresh" content="0;url=
        mailto:
        ?bcc={% for priv_mail in priv_mails %}{{ priv_mail }}{% if not forloop.last %},%20{% endif %}{% endfor %}" />

    {% endif %}

{% elif comp_mails %}

     <meta http-equiv="refresh" content="0;url=
     mailto:{% for comp_mail in comp_mails %}{{ comp_mail }}{% if not forloop.last %},%20{% endif %}{% endfor %}" />

{% endif %}

```

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 18, 2023, 6:44pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/11 "2023-04-18T18:44:19Z")

</div>

NEXT nebwie question on same topic: Now i have to deal with the char-number-limitation of mailto-hand-overs. Is there a way to count the chars in a POST-Array?

I tried several approaches with “len”, “Length” or “count” but the best result was the correct number of eMail adresses in the given POST, but i would need the sum off all CHARS in POST…

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 18, 2023, 6:55pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/12 "2023-04-18T18:55:31Z")

</div>

I’m not aware of any way of doing it in the template language. You could either write some JavaScript to calculate it, or calculate it in the view before rendering the data in the template.

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 18, 2023, 7:10pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/13 "2023-04-18T19:10:58Z")

</div>

preferred solution would be to calculate it in the view. something like request.POST[‘eMail’].totalcharcount 😉

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 18, 2023, 7:18pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/14 "2023-04-18T19:18:48Z")

</div>

You’ll need to calculate the sum of the lengths of the individual strings in the list.

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 18, 2023, 7:37pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/15 "2023-04-18T19:37:04Z")

</div>

so something like

```auto
elements=request.POST.getlist('eMail')
for element in elements:
   len(element)

```

but since i am still new to python i have no idea how to aggregate the single len-values or to sum it up…

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 18, 2023, 7:54pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/16 "2023-04-18T19:54:08Z")

</div>

think this could work. thx

```auto
            priv_mails = request.POST.getlist('eMail')
            comp_mails = request.POST.getlist('cMail')
            length_priv = 0
            length_comp = 0
            length_total = 0
            for priv_mail in priv_mails:
                length_priv += len(priv_mail)
            for comp_mail in comp_mails:
                length_comp += len(comp_mail)

            length_total = length_priv + length_comp
            print(length_total)

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 18, 2023, 8:17pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/17 "2023-04-18T20:17:28Z")

</div>

You could do something like:  
`length_priv = sum([len(email) for email in request.POST.getlist('eMail')])`

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [April 18, 2023, 9:28pm UTC](https://forum.djangoproject.com/t/handing-over-emails-from-post-to-standard-mail-app/20185/18 "2023-04-18T21:28:32Z")

</div>

I will try, could shorten the code a bit. Thx for Yoru help 🙂
