How to send html mail with Content-ID header using mutt in command line - bash

I was trying to send a html mail with images. But I am not familiar with mail headers, how can I add a image tag using cid, i.e. attach an image and make it shown in the html content?
<img src="cid:x">
This is my testing command:
mutt -s "test" jason#example.com \
-e "set content_type=text/html" \
-a /path/to/image <<MAIL
<img src="cid:0">
MAIL

It seems that this is a new feature onging in neomutt project.
Currently there's no way to add Content-ID header for attachments.
See PR: https://github.com/neomutt/neomutt/pull/2049.

Related

run cURL to upload a file without header

My aim is to upload the given file to service_now and I use the below code in shell script to do it. $ values are declared, where SERVICENOW_API_URL=https://dev80516.service-now.com/api/now/attachment/file and table_name is sys_attachment.
$ curl $SERVICENOW_API_URL?table_name=$SERVICENOW_ATTACHMENT_TABLE_NAME\&table_sys_id=$SERVICENOW_ATTACHMENT_TABLE_SYS_ID\&file_name=$UPLOAD_FILE_NAME --request POST --header \"Accept:application/json\" --user $SERVICENOW_USER_NAME:$SERVICENOW_PASSWORD --header \"Content-Type\:application/json\" -F "uploadFile=#./blank.txt"
Whenever I upload a file, the uploaded file has the below type of headers added to it. Please make changes in my command to upload the file without this header.
--------------------------565a353520eb07b1
Content-Disposition: form-data; name="uploadFile"; filename="blank.txt"
Content-Type: text/plain
--------------------------565a353520eb07b1--
Also when the zipped file is uploaded to service_now and then downloaded back from serviceNow, unable to extract/unzip the file.
Wow, it seems command substitution with backticks works perfectly with text files
-F "uploadFile=`cat blank.txt`"

Send mail using mpack without attachment

How can I send mail without attachment?
mpack -s 'SUBJECT' message.txt $To
This shows the message.txt file sometimes as a body while receiving mail and sometimes it shows file attachment while receiving the same mail. I need to show always text in this file as a mail body.

mailx not working but sendmail is working

Recently my production server has been upgraded. after that our mailx command is not working. it is sending the mail without attachment and then there is junk character in mail.
error is like.
Hello Team,
Please find the attached list of files which have been purged.
Regards,
Axiom Tech Support
begin 644 purge_files_2018-07-07.log.gz
M'XL("&,005L``W!U<F=E7V9I;&5S7S(P,3#M,#<M,#<N;&]G`-2=6V^<-Y*&
M[^=7]/4"M'DF*W>)DVQF,3/Q1#[V8K!H%,DJ6[`L"9*3&<^OGY=JM91(:K5R
ML=W?.#8LRVZ#1=;A>8N'_-V6U_CIK:LKE[ZR^&G_]ZO5R6>Y7+GY*U]]7OUR
MN;K0U>4O5^]E/?#SK\?IU?6KC]<?_O0?__<__K2Z^>_OSPS4?[5ZB\&=GK]?
MG7S]=C6'N%*1<;VZ.!MRM?K\#<]7KEK\R9?K`XWYN?&&^_&^.?EI&>/=,<?N
MJ3'_\.-//Y_\_QAVO!_VG_]V\N[KO[WY;O7?[WY:_=>/WYS<#EY/SV1AGO+4
MK/_YAS?+F?(_,.UG%^^?F.)TN!&_YLO+Z]?\S].+3VM\N?FJO,:XKE]?R]6O
the existing command was like
uuencode purge_files_2018-07-07.log.gz purge_files_2018-07-07.log.gz | mailx "Subject:Purge file";echo -e "\nHello Team,\n\nPlease find the attached list of files which have been purged -s onkar.tiwar90#gmail.com
now I have replaced it with
echo "Subject:Purge file";echo -e "\nHello Team,\n\nPlease find the attached list of files which have been purged.\n\nRegards,\nAxiom Tech Support";/usr/bin/uuencode purge_files_2018-07-07.log.gz purge_files_2018-07-07.log.gz)|/usr/sbin/sendmail -t "onkar.tiwar90#gmail.com"
So my question is why mailx is not working but sendmail is working. actually i will have to change in multiple scripts so I am seeking the solution.
Mailx upgrade switched it to use MIME as mail content instead of plain text. Your email client does not recognise uuencoded content within MIME.
You can stop using uuencode and switch to
mailx -a <filename>

"From" address in mutt not working

Refer this
Change sender's address in mutt via console
I have same issue in a shell script using mutt. Tried updating the header (-e), sending env variable EMAIL, updated ~/.muttrc (There is no entry in /etc/Muttrc so that does not have an effect) but no change.I still get "From" address as what is set by host.
Please help.
I tried some more options and this is what eventually worked.
$MUTT -e "set from=DoNotReply" -s "$MAIL_SUBJECT" -a $FILE_LIST -- $MAIL_RECEPIENTS
Set set use_envelope_from = yes in your .muttrc. This adds the -f option when calling
sendmail to deliver the mail, forcing it to use the same address for the envelope as for the From: header field.

Using CURL to download file and view headers and status code

I'm writing a Bash script to download image files from Snapito's web page snapshot API. The API can return a variety of responses indicated by different HTTP response codes and/or some custom headers. My script is intended to be run as an automated Cron job that pulls URLs from a MySQL database and saves the screenshots to local disk.
I am using curl. I'd like to do these 3 things using a single CURL command:
Extract the HTTP response code
Extract the headers
Save the file locally (if the request was successful)
I could do this using multiple curl requests, but I want to minimize the number of times I hit Snapito's servers. Any curl experts out there?
Or if someone has a Bash script that can respond to the full documented set of Snapito API responses, that'd be awesome. Here's their API documentation.
Thanks!
Use the dump headers option:
curl -D /tmp/headers.txt http://server.com
Use curl -i (include HTTP header) - which will yield the headers, followed by a blank line, followed by the content.
You can then split out the headers / content (or use -D to save directly to file, as suggested above).
There are three options -i, -I, and -D
> curl --help | egrep '^ +\-[iID]'
-D, --dump-header FILE Write the headers to FILE
-I, --head Show document info only
-i, --include Include protocol headers in the output (H/F)

Resources