Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.networking > #2248 > unrolled thread

Trying to utilize mailx to send mail via apython script

Started byFerrous Cranus <nikos@superhost.gr>
First post2013-09-05 19:11 +0300
Last post2013-09-09 01:57 +0200
Articles 5 on this page of 45 — 7 participants

Back to article view | Back to comp.os.linux.networking


Contents

  Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 19:11 +0300
    Re: Trying to utilize mailx to send mail via  apython script Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-09-05 18:13 +0000
      Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-06 09:19 +0300
        Re: Trying to utilize mailx to send mail via  apython script Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-09-06 08:50 +0000
          Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-06 12:06 +0300
            Re: Trying to utilize mailx to send mail via  apython script "Jonathan N. Little" <lws4art@gmail.com> - 2013-09-06 14:10 -0400
              Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-07 08:33 +0300
                Re: Trying to utilize mailx to send mail via  apython script "Jonathan N. Little" <lws4art@gmail.com> - 2013-09-07 08:33 -0400
                  Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-07 23:24 +0300
                    Re: Trying to utilize mailx to send mail via  apython script "Jonathan N. Little" <lws4art@gmail.com> - 2013-09-07 16:54 -0400
                      Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-08 09:58 +0300
                        Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-08 10:57 +0300
                        Re: Trying to utilize mailx to send mail via  apython script "Jonathan N. Little" <lws4art@gmail.com> - 2013-09-08 10:11 -0400
                          Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-08 17:16 +0300
                            Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-08 18:23 -0700
                              Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-08 18:35 -0700
                                Re: Trying to utilize mailx to send mail via  apython script "Jonathan N. Little" <lws4art@gmail.com> - 2013-09-09 17:11 -0400
                                  Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-09 14:40 -0700
                                    Re: Trying to utilize mailx to send mail via  apython script "Jonathan N. Little" <lws4art@gmail.com> - 2013-09-09 18:15 -0400
                        Re: Trying to utilize mailx to send mail via  apython script David Brown <david.brown@removethis.hesbynett.no> - 2013-09-08 16:42 +0200
                          Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-08 18:41 +0300
                            Re: Trying to utilize mailx to send mail via  apython script Whiskers <catwheezel@operamail.com> - 2013-09-08 17:56 +0100
                              Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-09 11:09 +0300
                                Re: Trying to utilize mailx to send mail via  apython script Whiskers <catwheezel@operamail.com> - 2013-09-09 21:31 +0100
                        Re: Trying to utilize mailx to send mail via  apython script Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-09-09 19:35 +0000
    Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-06 00:22 -0700
      Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-06 11:09 +0300
        Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-07 15:39 -0700
        Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-07 15:41 -0700
      Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-07 16:20 -0700
        Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-08 09:54 +0300
          Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-08 13:15 -0700
            Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-09 11:29 +0300
              Re: Trying to utilize mailx to send mail via  apython script Todd <Todd@invalid.invalid> - 2013-09-09 11:44 -0700
              Re: Trying to utilize mailx to send mail via  apython script Whiskers <catwheezel@operamail.com> - 2013-09-09 22:07 +0100
                Re: Trying to utilize mailx to send mail via  apython script "Jonathan N. Little" <lws4art@gmail.com> - 2013-09-09 17:33 -0400
                  Re: Trying to utilize mailx to send mail via  apython script Whiskers <catwheezel@operamail.com> - 2013-09-10 16:38 +0100
                    Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-10 22:37 +0300
                      Re: Trying to utilize mailx to send mail via  apython script David Brown <david.brown@removethis.hesbynett.no> - 2013-09-10 23:04 +0200
                      Re: Trying to utilize mailx to send mail via  apython script Whiskers <catwheezel@operamail.com> - 2013-09-10 22:05 +0100
    Re: Trying to utilize mailx to send mail via  apython script David Brown <david@westcontrol.removethisbit.com> - 2013-09-06 11:10 +0200
      Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-06 12:17 +0300
        Re: Trying to utilize mailx to send mail via  apython script David Brown <david.brown@removethis.hesbynett.no> - 2013-09-08 16:34 +0200
          Re: Trying to utilize mailx to send mail via  apython script Ferrous Cranus <nikos@superhost.gr> - 2013-09-08 18:37 +0300
            Re: Trying to utilize mailx to send mail via  apython script David Brown <david.brown@removethis.hesbynett.no> - 2013-09-09 01:57 +0200

Page 3 of 3 — ← Prev page 1 2 [3]


#2255

FromDavid Brown <david@westcontrol.removethisbit.com>
Date2013-09-06 11:10 +0200
Message-ID<ytydndBJypiLAbTPnZ2dnUVZ8nSdnZ2d@lyse.net>
In reply to#2248
On 05/09/13 18:11, Ferrous Cranus wrote:
> 
> 
> i as root just installed
> 
> sendmail and mailx. i have edited the ~/.mailrc to use:
> 
> 
> nikos@superhost.gr [~/www/cgi-bin]# cat ~/.mailrc
> account gmail {
> set smtp-use-starttls
> set smtp=smtp://smtp.gmail.com:587
> set smtp-auth=login
> set smtp-auth-user=may)gmail
> set smtp-auth-password=my_gmail_pass_not_stupid_enough_to_wite _it_again
> }e
> 
> 
> 
> And now i'm trying  to:
> 
> 
> cmd = "echo %s | mailx -A gmail -r %s -s %s %s"  %  (MESSAGE, FROM,
> SUBJECT, TO)
> p=subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE )
> output, errors = p.communicate()
> print( errors, output )
> 
> 
> Any ideas please why this fails to work?
> while i remove the '-A gmail' string in the cmd line then i can send
> fast mail but only to mail containing the @superhost.gr trail.
> 
> i need to be eble to send to external mails to.

The obvious question here is why are you trying to use sendmail and
mailx?  You are writing a script in Python, and you want to send mail
via an SMTP server.  Just use Python's SMTP module.

[toc] | [prev] | [next] | [standalone]


#2256

FromFerrous Cranus <nikos@superhost.gr>
Date2013-09-06 12:17 +0300
Message-ID<l0c6jm$38m$1@dont-email.me>
In reply to#2255
Στις 6/9/2013 12:10 μμ, ο/η David Brown έγραψε:
> On 05/09/13 18:11, Ferrous Cranus wrote:
>>
>>
>> i as root just installed
>>
>> sendmail and mailx. i have edited the ~/.mailrc to use:
>>
>>
>> nikos@superhost.gr [~/www/cgi-bin]# cat ~/.mailrc
>> account gmail {
>> set smtp-use-starttls
>> set smtp=smtp://smtp.gmail.com:587
>> set smtp-auth=login
>> set smtp-auth-user=may)gmail
>> set smtp-auth-password=my_gmail_pass_not_stupid_enough_to_wite _it_again
>> }e
>>
>>
>>
>> And now i'm trying  to:
>>
>>
>> cmd = "echo %s | mailx -A gmail -r %s -s %s %s"  %  (MESSAGE, FROM,
>> SUBJECT, TO)
>> p=subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE )
>> output, errors = p.communicate()
>> print( errors, output )
>>
>>
>> Any ideas please why this fails to work?
>> while i remove the '-A gmail' string in the cmd line then i can send
>> fast mail but only to mail containing the @superhost.gr trail.
>>
>> i need to be eble to send to external mails to.
>
> The obvious question here is why are you trying to use sendmail and
> mailx?  You are writing a script in Python, and you want to send mail
> via an SMTP server.  Just use Python's SMTP module.
>
Liek this you mean:

		# open Gmail's SMTP server
		#server = smtplib.SMTP('smtp.gmail.com:587')
		#server.ehlo()
		#server.starttls()

		# next, log in to the server
		#server.login("my@gmail.com", "my_pass")


Because GMail tend to add a Sender field when receiving my mail 
supresing the real FROM field used in the webform to my Gmail's auth 
account.

I want to avoid that by using my own mail server so my mails appear for 
the correct client mail and not all of them from as coming from my GMail 
account/


-- 
Webhost <http://superhost.gr>

[toc] | [prev] | [next] | [standalone]


#2271

FromDavid Brown <david.brown@removethis.hesbynett.no>
Date2013-09-08 16:34 +0200
Message-ID<0rOdnZL-mtiaFrHPnZ2dnUVZ7qCdnZ2d@lyse.net>
In reply to#2256
On 06/09/13 11:17, Ferrous Cranus wrote:
> Στις 6/9/2013 12:10 μμ, ο/η David Brown έγραψε:
>> On 05/09/13 18:11, Ferrous Cranus wrote:
>>>
>>>
>>> i as root just installed
>>>
>>> sendmail and mailx. i have edited the ~/.mailrc to use:
>>>
>>>
>>> nikos@superhost.gr [~/www/cgi-bin]# cat ~/.mailrc
>>> account gmail {
>>> set smtp-use-starttls
>>> set smtp=smtp://smtp.gmail.com:587
>>> set smtp-auth=login
>>> set smtp-auth-user=may)gmail
>>> set smtp-auth-password=my_gmail_pass_not_stupid_enough_to_wite _it_again
>>> }e
>>>
>>>
>>>
>>> And now i'm trying  to:
>>>
>>>
>>> cmd = "echo %s | mailx -A gmail -r %s -s %s %s"  %  (MESSAGE, FROM,
>>> SUBJECT, TO)
>>> p=subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE )
>>> output, errors = p.communicate()
>>> print( errors, output )
>>>
>>>
>>> Any ideas please why this fails to work?
>>> while i remove the '-A gmail' string in the cmd line then i can send
>>> fast mail but only to mail containing the @superhost.gr trail.
>>>
>>> i need to be eble to send to external mails to.
>>
>> The obvious question here is why are you trying to use sendmail and
>> mailx?  You are writing a script in Python, and you want to send mail
>> via an SMTP server.  Just use Python's SMTP module.
>>
> Liek this you mean:
>
>          # open Gmail's SMTP server
>          #server = smtplib.SMTP('smtp.gmail.com:587')
>          #server.ehlo()
>          #server.starttls()
>
>          # next, log in to the server
>          #server.login("my@gmail.com", "my_pass")
>
>
> Because GMail tend to add a Sender field when receiving my mail
> supresing the real FROM field used in the webform to my Gmail's auth
> account.
>
> I want to avoid that by using my own mail server so my mails appear for
> the correct client mail and not all of them from as coming from my GMail
> account/
>

I have no experience with GMail, but there you can put whatever you want 
in the sender field (or any other field) when you connect to an SMTP 
server.  And the SMTP server can always choose to override fields with 
its own settings if it wants.  This applies equally to when you are 
using Python's SMTP module to connect to the GMail server, or when you 
send first to one SMTP server and relay on to GMail.

Since Python's SMTP module "speaks" SMTP to gmail, and any other mail 
program or MTA that will send mail via a gmail relay also "speaks" SMTP 
for that transfer, I would be very surprised if there is some effect you 
can get with an additional program or relay that you cannot get by using 
Python directly.

Your ISP should also have an SMTP server that you can connect to in the 
same way (via Python), and send it on that way.

[toc] | [prev] | [next] | [standalone]


#2273

FromFerrous Cranus <nikos@superhost.gr>
Date2013-09-08 18:37 +0300
Message-ID<l0i5j5$nfn$1@dont-email.me>
In reply to#2271
Στις 8/9/2013 5:34 μμ, ο/η David Brown έγραψε:
> On 06/09/13 11:17, Ferrous Cranus wrote:
>> Στις 6/9/2013 12:10 μμ, ο/η David Brown έγραψε:
>>> On 05/09/13 18:11, Ferrous Cranus wrote:
>>>>
>>>>
>>>> i as root just installed
>>>>
>>>> sendmail and mailx. i have edited the ~/.mailrc to use:
>>>>
>>>>
>>>> nikos@superhost.gr [~/www/cgi-bin]# cat ~/.mailrc
>>>> account gmail {
>>>> set smtp-use-starttls
>>>> set smtp=smtp://smtp.gmail.com:587
>>>> set smtp-auth=login
>>>> set smtp-auth-user=may)gmail
>>>> set smtp-auth-password=my_gmail_pass_not_stupid_enough_to_wite
>>>> _it_again
>>>> }e
>>>>
>>>>
>>>>
>>>> And now i'm trying  to:
>>>>
>>>>
>>>> cmd = "echo %s | mailx -A gmail -r %s -s %s %s"  %  (MESSAGE, FROM,
>>>> SUBJECT, TO)
>>>> p=subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE )
>>>> output, errors = p.communicate()
>>>> print( errors, output )
>>>>
>>>>
>>>> Any ideas please why this fails to work?
>>>> while i remove the '-A gmail' string in the cmd line then i can send
>>>> fast mail but only to mail containing the @superhost.gr trail.
>>>>
>>>> i need to be eble to send to external mails to.
>>>
>>> The obvious question here is why are you trying to use sendmail and
>>> mailx?  You are writing a script in Python, and you want to send mail
>>> via an SMTP server.  Just use Python's SMTP module.
>>>
>> Liek this you mean:
>>
>>          # open Gmail's SMTP server
>>          #server = smtplib.SMTP('smtp.gmail.com:587')
>>          #server.ehlo()
>>          #server.starttls()
>>
>>          # next, log in to the server
>>          #server.login("my@gmail.com", "my_pass")
>>
>>
>> Because GMail tend to add a Sender field when receiving my mail
>> supresing the real FROM field used in the webform to my Gmail's auth
>> account.
>>
>> I want to avoid that by using my own mail server so my mails appear for
>> the correct client mail and not all of them from as coming from my GMail
>> account/
>>
>
> I have no experience with GMail, but there you can put whatever you want
> in the sender field (or any other field) when you connect to an SMTP
> server.  And the SMTP server can always choose to override fields with
> its own settings if it wants.  This applies equally to when you are
> using Python's SMTP module to connect to the GMail server, or when you
> send first to one SMTP server and relay on to GMail.
>
> Since Python's SMTP module "speaks" SMTP to gmail, and any other mail
> program or MTA that will send mail via a gmail relay also "speaks" SMTP
> for that transfer, I would be very surprised if there is some effect you
> can get with an additional program or relay that you cannot get by using
> Python directly.
>
> Your ISP should also have an SMTP server that you can connect to in the
> same way (via Python), and send it on that way.
>
>

If i setup some mail server on localhost can i alter the from field to 
the one i want and suppress the hostname of the server?

Thai is what i want to know.

GMail doesnt care what you tell it to be the FROM field, it always ads 
up an authenticated Sender address into the headers and also display the 
hostname used to directly connect to it.


-- 
Webhost <http://superhost.gr>

[toc] | [prev] | [next] | [standalone]


#2277

FromDavid Brown <david.brown@removethis.hesbynett.no>
Date2013-09-09 01:57 +0200
Message-ID<qPGdncOie7Z8k7DPnZ2dnUVZ8qadnZ2d@lyse.net>
In reply to#2273
On 08/09/13 17:37, Ferrous Cranus wrote:
> Στις 8/9/2013 5:34 μμ, ο/η David Brown έγραψε:
>> On 06/09/13 11:17, Ferrous Cranus wrote:
>>> Στις 6/9/2013 12:10 μμ, ο/η David Brown έγραψε:
>>>> On 05/09/13 18:11, Ferrous Cranus wrote:
>>>>>
>>>>>
>>>>> i as root just installed
>>>>>
>>>>> sendmail and mailx. i have edited the ~/.mailrc to use:
>>>>>
>>>>>
>>>>> nikos@superhost.gr [~/www/cgi-bin]# cat ~/.mailrc
>>>>> account gmail {
>>>>> set smtp-use-starttls
>>>>> set smtp=smtp://smtp.gmail.com:587
>>>>> set smtp-auth=login
>>>>> set smtp-auth-user=may)gmail
>>>>> set smtp-auth-password=my_gmail_pass_not_stupid_enough_to_wite
>>>>> _it_again
>>>>> }e
>>>>>
>>>>>
>>>>>
>>>>> And now i'm trying  to:
>>>>>
>>>>>
>>>>> cmd = "echo %s | mailx -A gmail -r %s -s %s %s"  %  (MESSAGE, FROM,
>>>>> SUBJECT, TO)
>>>>> p=subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE )
>>>>> output, errors = p.communicate()
>>>>> print( errors, output )
>>>>>
>>>>>
>>>>> Any ideas please why this fails to work?
>>>>> while i remove the '-A gmail' string in the cmd line then i can send
>>>>> fast mail but only to mail containing the @superhost.gr trail.
>>>>>
>>>>> i need to be eble to send to external mails to.
>>>>
>>>> The obvious question here is why are you trying to use sendmail and
>>>> mailx?  You are writing a script in Python, and you want to send mail
>>>> via an SMTP server.  Just use Python's SMTP module.
>>>>
>>> Liek this you mean:
>>>
>>>          # open Gmail's SMTP server
>>>          #server = smtplib.SMTP('smtp.gmail.com:587')
>>>          #server.ehlo()
>>>          #server.starttls()
>>>
>>>          # next, log in to the server
>>>          #server.login("my@gmail.com", "my_pass")
>>>
>>>
>>> Because GMail tend to add a Sender field when receiving my mail
>>> supresing the real FROM field used in the webform to my Gmail's auth
>>> account.
>>>
>>> I want to avoid that by using my own mail server so my mails appear for
>>> the correct client mail and not all of them from as coming from my GMail
>>> account/
>>>
>>
>> I have no experience with GMail, but there you can put whatever you want
>> in the sender field (or any other field) when you connect to an SMTP
>> server.  And the SMTP server can always choose to override fields with
>> its own settings if it wants.  This applies equally to when you are
>> using Python's SMTP module to connect to the GMail server, or when you
>> send first to one SMTP server and relay on to GMail.
>>
>> Since Python's SMTP module "speaks" SMTP to gmail, and any other mail
>> program or MTA that will send mail via a gmail relay also "speaks" SMTP
>> for that transfer, I would be very surprised if there is some effect you
>> can get with an additional program or relay that you cannot get by using
>> Python directly.
>>
>> Your ISP should also have an SMTP server that you can connect to in the
>> same way (via Python), and send it on that way.
>>
>>
>
> If i setup some mail server on localhost can i alter the from field to
> the one i want and suppress the hostname of the server?
>
> Thai is what i want to know.
>
> GMail doesnt care what you tell it to be the FROM field, it always ads
> up an authenticated Sender address into the headers and also display the
> hostname used to directly connect to it.
>
>

One last time - you can do /exactly/ the same thing from Python.

<http://docs.python.org/2/library/smtplib.html#smtp-example>

And again, /don't/ do this with other people's email addresses.  Unless 
you are specifically making a website with this intention (i.e., a 
web-based email client), then this is verging on fraud.  It is certainly 
not what users would expect or like.

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | comp.os.linux.networking


csiph-web