- Ubuntu 14.04 on a virtual machine that is not my PC. I use my PC (Windows 7 and Putty 0.63) to shell into it.
- Uname=Linux ubuntucomp 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
- This machine is on our private network and does not have an official registered domain name. It has it's own IP but I think it's an internal IP. This machine is not accessed from outside our network, I only use it to send outgoing emails to people in our company. I got Perl to send an email out to our SMTP provider and that works fine.
- We pay for an external SMTP service, so that part is done. The only SMTP authentication I use is a username and password. SSL is not needed.
- I have no intention of receiving any email from the outside world on this machine.
- Right now my emails are being blocked by my SMTP provider, possibly because I don't have a FQDN. The error I get is "connection timed out".
- I can't even telnet from my PC to the SMTP server, I also get a "timeout" error. I used Putty 0.63. Yet I can still send email via a Perl program on Ubuntu.
- IT cannot help me so I'm on my own. I'm new to sysadmin for Ubuntu.
I need a way to send emails with an attachment via the command line (for an automated cron process) without setting up a registered domain, MX or A record. What are my options? Postfix won't do this as it requires a bunch of network settings set up along with a (DNS?) record.
Since the Perl module uses the SMTP protocol to directly log into the SMTP server, I suspect I need an Ubuntu package that does the same, without passing the task onto another MTA.
I tried SSMTP
- Using ssmtp I got this error from /var/log/mail.log: Oct 22 10:18:19 ubuntucomp sSMTP[16075]: Unable to connect to "smtpout.payserv.net" port 587. Process failed with error code 1. Oct 22 10:18:19 ubuntucomp sSMTP[16075]: Cannot open smtpout.payserv.net:587
- In /etc/ssmtp/ssmtp.conf I even changed the setting "Rewritedomain" to be our actual company domain name.
- And how do I restart the SSMTP daemon after I make changes to the ssmtp.conf file? Perhaps that's part of the problem.
I tried telnetting into the SMTP server
- I tried telnetting into smtpout.payserv.net port 25 and just got "220 *******************", then Putty 0.63 quit.
Is it possible my SMTP company has blocked my IP? Should I just call them?
Let's back up a bit
- I did 'netstat -an|grep smtp' and did not see an smtp service running. How do I start it?
- Do I need to add the smtp server to /etc/hosts?
Thanks.
You can use mail option from Linux command line. Default format is given below.
To add content to the body of the mail while running the command you can use the following options. If you want to add text on your own:
And if you want mail to read the content from a file:
Some other useful options in the mail command are:
-s
subject (The subject of the mail)-c
email-address (Mark a copy to this “email-address”, or CC)-b
email-address (Mark a blind carbon copy to this “email-address”, or BCC) Here’s how you might use these options:To add attachments u can use the
-a
option in mailHope this helps.
Got it! In /etc/ssmtp/ssmtp.conf, the line "hostname=" should be my machine's name "ubuntucomp.net". That's all that was wrong.
However it does not send attachments. It seems other people have had the same problem: how to send an email with an attachment without installing an MTA. And I can't find a solution so far.