renderSendMail not sending mails - email

I try to send simple mail from Haskell's Network.Mail.Mime (package mime-mail) by
renderSendMail $ simpleMail' (Address Nothing "myEMailHere")
(Address (Just "TESTER") "myEMailHere") "TEST" "TESTING"
It executes without any warnings or exceptions, but the email is not sent. However
echo "TEST" | sendmail -v "myEMailHere"
works as expected. I have tried using renderMailCustom and giving arguments to sendmail as above, but despite I got same info as sendmail's output ("Mail Delivery Status Report will be mailed to username."), I didn't receive any E-Mail.
What am I doing wrong here?

Since your sendmail is in a different location than what mime-mail is expecting, you will need to inform it of the correct location. The exact right incantation depends a little bit on how you are installing mime-mail; in the simplest case, where you are installing it with cabal install, try this:
cabal install --ghc-option -DMIME_MAIL_SENDMAIL_PATH='"'`which sendmail`'"' mime-mail
Other tools than cabal-install should have the ability to be informed of this CPP directive in a similar way.

Related

Unix mail command queues but does not send

I have created a service that is supposed to send an automated email in HTML format by using UNIX mail command. It was working correctly until yesterday when suddenly stopped sending mails.
This is the command Im running programmatically
cat ./email.txt | mail -v -s "$(echo -e "Report for Last Week
Content-Type: text/html
Reply-to: abraham#corp.com
From: abraham#corp.com")" abraham#corp.com manolo#corp.com
The output looks like:
abraham#corp.com... queued
manolo#corp.com... queued
I am not getting any email, neither my partner...
I am not even able to run
echo "test"|mail -s "This is a test" abraham#corp.com
Im running on RedHat Linux.
Just in case someone needs help. The issue was related to the sendmail service of the OS.
I had to go service sendmail restart
It was as simple as that, however, I did compare the configuration files against a clean machine to make sure they were similar.

Mutt returns error from cmd line: Bad IDN in "from":

When trying to issue this command to send a file attachment from the command line I'm getting an error:
Bad IDN in "from": 'sd3.È'
sd3 is the name of my host.
The command I'm executing is:
echo "See attached file" | /usr/bin/mutt -a file.txt -s File:file.txt -- myemail#domain.com
I recently cloned an existing Centos7 server (made a copy of the virtual machine and spawned it as a second instance under a different IP) and everything has been working perfectly for awhile as far as I can tell. Not sure if that's relevant to this but it could be an indicator of what needs adjusting.
On the original server I cloned, I can run this command on without any error. I uninstalled mutt and re-installed it and I'm still getting the error.
.muttrc looks like this:
set mbox_type=Maildir
set folder="~/Maildir"
set mask="!^\\.[^.]"
set mbox="~/Maildir"
set record="+.Sent"
set postponed="+.Drafts"
set spoolfile="~/Maildir"
I also compared the /etc/Muttrc and /etc/Muttrc.local files and they're identical between the two systems. (Muttrc.local is empty)
Running the latest version of Mutt under CentOS7: Mutt 1.5.21 (2010-09-15)
So on two almost-identical servers, one runs, one doesn't. Any ideas what might be wrong?
I encountered the same problem and it was simply solved by setting the from variable in ~/.muttrc (in fact, the file didn't exist before and this is the only thing my .muttrc contains now):
set from="something#something.com"
I was smashing my head the entire day on this issue as I'm not permitted allow to installed outside of redhat repo
I found a workaround that is using option -x
-x Emulate the mailx compose mode.
echo "This is a test message" | mutt -x -s "Test Mail" john.smith#example.com
Setting the following environment variables worked for me.
EMAIL=default#company.com
REPLYTO=$EMAIL
export EMAIL REPLYTO
After a ton of research, there appears to be some obscure bugs that are still in this stable version of mutt - which is the standard package release on CentOS7.
First I removed my old version:
yum remove mutt.x86_64
I ended up downloading the latest source of mutt, 1.9.0 from mutt.org and manually compiling and installing it.
In order to compile the source version of Mutt, I also needed to run:
yum install ncurses-devel
Now the command works without this "bad IDN" error.
It appears CentOS 7.3 had mutt-1.5.21-26.el7.x86_64 and CentOS 7.4 now has mutt-1.5.21-27.el7.x86_64.
If you don't want to compile/install from source, I found that a Fedora 22 version (mutt-1.6.2-1.fc22.x86_64.rpm) works OK. I just removed the rpm that came from CentOS 7.4 and did a local install of the Fedora 22 rpm.
I ran into this working through some automated system builds (Centos7, Mutt 1.5.21).
Using strace and some other debugging it wasn't entirely clear what the issue was, but seemed to be circling dns/domain/hostname issues. I as able to get around/recreate the error by adding/remove the "search " in the /etc/resolv.conf file (works WITH a search domain).
Without a search domain, rendered the: Bad IDN in "from": ... error

Logrotate encryption before mailing

I use logrotate that sends me logs on a regular basis. My server is a VPS running Postfix as an outgoing-only SMTP server.
I would like all the mailed logs (which Logrotate sends) to be encrypted with PGP or S/MIME. How can I do that?
I searched for logrotate mail encryption, but couldn't find any. Therefore, I'm thinking that I can pass "nomail" command in logrotate config, but then add in the "postscript" a script to first encrypt the mail and then send.
So, is there a better way to encypt logrotate mail with PGP? Or that's what I need to do? I would appreciate any advise or an example of such a script.
Also, I'm not considering to use TLS as there are possible ways to bypass it in the SMTP server. And I would rather rely on encryption of individual messages.
Thanks!
Edit:
Here is my script I'm using for custom email sending(Without GPG for now):
#!/bin/bash
read MSG
echo $MSG | mail -s $1 $2
But when I force rotate with logrotate --mail=loggpg.sh --force /etc/logrotate.d/ufw I keep getting error about uncompression, do I need to manually uncompress it? Or there is smth wrong with the script?
Error I get:
error: mail command failed for /var/log/ufw.log.5.gz
error: uncompress command failed mailing /var/log/ufw.log.5.gz`
You can execute logrotate with --mail command line option. It will allow you to use your own shell/perl/python script to send email instead of default /bin/mail -s.
man logrotate
OPTIONS
...
-m, --mail
Tells logrotate which command to use when mailing logs. This command should accept two arguments: 1) the subject of the message, and
2) the recipient. The command must then read a message on standard input and mail it to the recipient. The default mail command is
/bin/mail -s.

How do I use the MOSS script?

I am trying to run MOSS on my Mac OS X and I don't know what mistake I am making. I am not sure whether I am running the command properly or not. I downloaded this file as 'moss', gave this execution permissions and tried to run following:
./moss -l python -c "Assignment 1" -d assignment1/
I got the response as
Checking files . . .
OK
Which is wrong. The assignment1 directory has 4 python scripts. Two files are exactly similar, in one I have rearranged the code and in another I have changed the variable names.
I have sent the email for registration and I have not received any reply. So I am running the code with default user ID.
I also tried running it with sending each of those python files instead of working on a directory, still I get same response.
./moss -l python -c "Assignment 1" 1.py 2.py 3.py 4.py
Steps to get going with MOSS on your Mac:
Send an email at moss#moss.stanford.edu with the mail body containing the email you want to register.
Eg:
registeruser
mail "username#domain" <-- your email
You will then get a reply containing the script that you will need to save as “moss.pl”. Just make sure that your Mac has the “perl” folder within the “/usr/bin/“ folder. Else, change the path of the perl folder on the very first line of the script to be compatible to your machine.
Now set the execute permission using the command “chmod ug+x moss.pl”. This should allow you to send your queries to the Stanford server. If you were to not execute this command then you may be denied the permission to submit any queries.
Now submit the query to the server using the command similar to the following (note the command is not restricted to a single flag (i.e. -l)….refer the comments in the script for USAGE instructions):
“./moss.pl -l python file_1.py file_2.py”
The result on submitting a query such as above would be:
Checking files . . .
OK
Uploading file_1.py ...done.
Uploading file_2.py ...done.
Query submitted. Waiting for the server's response.
http://moss.stanford.edu/results/282371307.
Just review if you have followed all the steps above. I, then, don't see you having any issues getting the results. Maybe you were facing issues bcoz you were not registered initially.
Seems one should be registered to use it, instructions weren't clear on the site. I received the email finally with userid and ran the script, this time it worked.
I think you should resend the email in the format:
registeruser
mail youremail
In the reply email you will get your ID, replace it in the script and run the moss file again. You should get the link for the result.

Using "email" command in Cygwin [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to use Cygwin to send an e-mail from the command line. This is what I am putting in:
email -f myaddress#blah.com -s "This is a test" -b toaddress#blah.com
I get this error message:
/bin/sh: /usr/lib/sendmail: No such file or directory
I created a folder in /usr/lib called "sendmail", and now I get this:
/bin/sh: /usr/lib/sendmail: is a directory
Can someone please give me a step-by-step on how to send an email from Cygwin? Like how to set it up and everything? I have looked everywhere and I am about ready to tear my hair out.
EDIT: Thanks for your responses guys. This is how I finally got it to work.
bash.exe -c "echo -e 'To: thepeopleimsendingitto#blah.com\nSubject: mySQL Upload\nSQL files from machines uploaded to log table successfully.' | sendmail -f me#blah.com otherpeople#blah.com"
Even though Cygwin was in my Windows path, it couldn't recognize it, so I had to run bash.exe directly and say "do this command as a Linux command". The echo is what is constructing the email itself. The \n characters separate it into "To", "Subject" and Body.
Apparently, email is a program that lets you submit an email message (a Mail Submission Agent) that relies on another program to actually send the message (a Mail Transfer Agent).
I enabled this on my Cygwin installation last week.
I am not using email but mutt, one of the alternatives Cygwin offers (see its package list).
I use mutt not only to submit the mail to be sent, but also to read it; it's a Mail User Agent (see some screenshots).
Like email, mutt relies on a Mail Transfer Agent to send mail, so I had to install one.
On Linux, popular choices are sendmail and postfix; but they do far more than you need and Cygwin doesn't offer them as packages. It does offer exim and ssmtp.
I installed the ssmtp package and ran the ssmtp-config utility. You have to make some decisions here. You must know which SMTP server you can use and whether you need any special configuration to communicate with it.
By the way, ssmtp does install an executable called sendmail, which is not the original sendmail, but behaves like it for the purposes you need it for.
Okay So i wasn't clear enough on my first attempt... I guess that is my fault, I will try to make this more clear.
In the mail-config it will ask for the sendmail binary. It should sound something like this :
Please enter the sendmail command line [/usr/sbin/sendmail -t -i]:
This is basically asking where is the sendmail binary installed and what parameters should i pass it to send a mail. Your sendmail binary is either not installed, or not installed in the location you are specifying.
To see if you have sendmail installed try
%sendmail;
If that works, to find the path of that binary try
%which sendmail;
If that does not work, either sendmail is not installed, or the location of sendmail needs to be appended to the env path variable. There no correct answer on how you want to set things up, but the minimum requirments to make this work is to have sendmail on the current machine, have it configured and pass the correct absolute path to the mail program in the mail-config.