Sendmail: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(35 intermediate revisions by the same user not shown)
Line 1: Line 1:
<source lang="properties">
<source lang="properties">
cat << EOF | sendmail -t  
cat << EOF | sendmail -t  
From: Sender <[email protected]>
From: Sender <[email protected].bd>
Reply-To: Sender <[email protected]>
Reply-To: Sender <[email protected].bd>
To: To <[email protected].bd>
CC: Cc <[email protected].bd>
Disposition-Notification-To: [email protected]
Disposition-Notification-To: [email protected].bd
Subject: Generic Subject
Subject: Generic Subject


Line 12: Line 12:
EOF
EOF
</source>
</source>
==Python SMTP==
sudo apt install python3.8-venv
python3 -m venv ~/.finology/xpresscover/tmp/sendmail
source ~/.finology/xpresscover/tmp/sendmail/bin/activate
<source lang="bash" highlight="3-6" line>
export ENV_EMAIL_FROM='Chorke Inc<[email protected]>';\
export ENV_EMAIL_TO='Academia<[email protected]>';\
export ENV_SMTP_USER='[email protected]';\
export ENV_SMTP_HOST='mail.chorke.org.bd';\
export ENV_SMTP_PASS='p@$$w0rd';\
export ENV_SMTP_PORT='587';\
export ENV_SMTP_TTLS='1';\
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/finology/commons/sendmail.sh.txt')
</source>
deactivate


==Knowledge==
==Knowledge==
/usr/sbin/sendmail -Am -v -t < filename.eml
/usr/sbin/sendmail -v -t < filename.eml
  /usr/sbin/sendmail -t < filename.eml
  /usr/sbin/sendmail -t < filename.eml
python3 -c 'import sys; print(sys.version_info[:])'
python_version="$(python -V 2>&1|sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')"
python_version_major=`echo $python_version|cut -d. -f1`
python_version_minor=`echo $python_version|cut -d. -f2`
python_version_build=`echo $python_version|cut -d. -f3`
python_version="$(python -V 2>&1|grep -Po '(?<=Python )(.+)')"
printf '%s' "$python_version"
echo python_version
'''launch interpreter by magic header or env'''
'''1. Python 3.9:''' #!/usr/bin/env python3.9
'''2. Python 2.6:''' #!/usr/bin/env python2.6
'''3. TS Node  :''' #!/usr/bin/env ts-node
'''4. Python    :''' #!/usr/bin/env python
'''5. NodeJS    :''' #!/usr/bin/env node
'''6. Ruby      :''' #!/usr/bin/env ruby
'''7. Perl      :''' #!/usr/bin/env perl
'''8. PHP      :''' #!/usr/bin/env php
'''9. GO        :''' #!/usr/bin/env go run
<source lang="bash">
#resolve mail server
nslookup
: '
Default Server:  www0.dev.chorke.org
Address:  10.20.13.100
> set type=mx
> chorke.org
Server:  www0.dev.chorke.org
Address:  10.20.13.100
Non-authoritative answer:
chorke.org      MX preference = 0, mail exchanger = mail.chorke.org
> exit
'
</source>


==References==
==References==
{|
{|
| valign="top" |
| valign="top" |
* [https://stackoverflow.com/questions/2429511/ Why Python script start with <code>#!/usr/bin/env python</code>?]
* [https://www.ibm.com/support/pages/configuring-sendmail-use-username-and-password-authentication Configuring SendMail to use username and password]
* [https://www.ibm.com/support/pages/configuring-sendmail-use-username-and-password-authentication Configuring SendMail to use username and password]
* [https://access.redhat.com/solutions/60803 Configure sendmail for relaying mail over port 587]
* [https://access.redhat.com/solutions/60803 Configure sendmail for relaying mail over port <code>587</code>]
* [https://stackoverflow.com/questions/34294251/ Capture debug output from Python <code>smtplib</code>]
* [https://access.redhat.com/solutions/6876 Setup and test SMTP AUTH within Sendmail]
* [https://access.redhat.com/solutions/6876 Setup and test SMTP AUTH within Sendmail]
* [https://stackoverflow.com/questions/1822425/ Sending mail from a Bash shell script]
* [https://stackoverflow.com/questions/1822425/ Sending mail from a Bash shell script]
Line 26: Line 88:
* [https://stackoverflow.com/questions/4728393/ Reply-To header to send emails]
* [https://stackoverflow.com/questions/4728393/ Reply-To header to send emails]
* [https://unix.stackexchange.com/questions/223636/ Sendmail Attachment]
* [https://unix.stackexchange.com/questions/223636/ Sendmail Attachment]
* [https://realpython.com/python-send-email/ Python Send Email]


| valign="top" |
| valign="top" |
* [https://stackoverflow.com/questions/37224073/ SMTP AUTH extension not supported by server]
* [https://stackoverflow.com/questions/4906977/ Python access environment variables]
* [https://stackoverflow.com/questions/16817646/ Extract version number from a string]
* [https://superuser.com/questions/363865/ Extract a version number using sed]
* [https://stackoverflow.com/questions/49904740/ Run remote Python script via curl]
* [https://stackoverflow.com/questions/6245293/ Extract version number from file]
* [https://stackoverflow.com/questions/6141581/ Detect python version in shell]
* [https://unix.stackexchange.com/questions/39407/ Check if MySQL is installed]


|}
|}

Latest revision as of 21:50, 21 March 2022

cat << EOF | sendmail -t 
Sender: [email protected]
From: Sender <[email protected]>
Reply-To: Sender <[email protected]>
To: To <[email protected]>
CC: Cc <[email protected]>
Disposition-Notification-To: [email protected]
Subject: Generic Subject

Generic Body
EOF

Python SMTP

sudo apt install python3.8-venv
python3 -m venv ~/.finology/xpresscover/tmp/sendmail
source ~/.finology/xpresscover/tmp/sendmail/bin/activate
export ENV_EMAIL_FROM='Chorke Inc<[email protected]>';\
export ENV_EMAIL_TO='Academia<[email protected]>';\
export ENV_SMTP_USER='[email protected]';\
export ENV_SMTP_HOST='mail.chorke.org.bd';\
export ENV_SMTP_PASS='p@$$w0rd';\
export ENV_SMTP_PORT='587';\
export ENV_SMTP_TTLS='1';\
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/finology/commons/sendmail.sh.txt')
deactivate

Knowledge

/usr/sbin/sendmail -Am -v -t < filename.eml
/usr/sbin/sendmail -v -t < filename.eml
/usr/sbin/sendmail -t < filename.eml
python3 -c 'import sys; print(sys.version_info[:])'
python_version="$(python -V 2>&1|sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')"
python_version_major=`echo $python_version|cut -d. -f1`
python_version_minor=`echo $python_version|cut -d. -f2`
python_version_build=`echo $python_version|cut -d. -f3`
python_version="$(python -V 2>&1|grep -Po '(?<=Python )(.+)')"
printf '%s' "$python_version"
echo python_version
launch interpreter by magic header or env
1. Python 3.9: #!/usr/bin/env python3.9
2. Python 2.6: #!/usr/bin/env python2.6
3. TS Node   : #!/usr/bin/env ts-node
4. Python    : #!/usr/bin/env python
5. NodeJS    : #!/usr/bin/env node
6. Ruby      : #!/usr/bin/env ruby
7. Perl      : #!/usr/bin/env perl
8. PHP       : #!/usr/bin/env php
9. GO        : #!/usr/bin/env go run
#resolve mail server
nslookup
: '
Default Server:  www0.dev.chorke.org
Address:  10.20.13.100

> set type=mx
> chorke.org
Server:  www0.dev.chorke.org
Address:  10.20.13.100

Non-authoritative answer:
chorke.org      MX preference = 0, mail exchanger = mail.chorke.org
> exit
'

References