Outils pour utilisateurs

Outils du site


issue140:tutoriel2

Ceci est une ancienne révision du document !


Suppose your email demands are rather modest and you just need to send occasional emails from your PC, especially if you like to send information from a job which is supposed to be run regularly. This may be a problem if you don't have access to the company email server. Webmail systems (such as Gmail) can be utilised, but they are ill-suited for this purpose and installing a full-featured email system on a PC would be a major undertaking. If your ISP's email offering is sufficiently reliable despite the various restrictions they will impose, then the sendemail command will be of some interest. Use of sendemail doesn't prevent you using full-featured email clients such as Thunderbird or webmail systems.

Sendemail makes use of a facility provided by most ISP's (but not all) who provide a simple direct route into their email servers. This will be via a so-called “smart host” (or email relay, mailhost or mailhub) - officially a MTA (Mail Transfer Agent) that simply passes any emails sent to it to your ISP's mail servers for onward delivery. In order that this route cannot easily be used to send spam, your ISP will impose some limitations. They will certainly not allow large numbers of emails to be sent and they may additionally require you to provide user/password details. But the principal check on your identity is that when you make your internet connection they allocate you an IP address from the pool of addresses owned by them, so your email can be identified as being sent by one of their customers. So it is definitely not a means of sending anonymous emails!

Your ISP should be able to give full details about using their smart host (or SMTP relay). But if not, whilst any list of ISPs and their smart hosts is almost certainly wrong or out of date, one site that may be worth trying is:- https://www.iw-webhosting.co.uk/smtp_hosts.htm Installation of the lightweight email sender (which needs no configuration) is straightforward:- sudo apt install sendemail This is designed to be used in shell scripts, or possibly from the command line. Because emails can take quite a variety of options, the parameters required can be rather lengthy.

The only required parameters are the senders email address, a destination address and the name of the smart host. Because email servers usually check that the IP address of the sender matches that recorded in the DNS system and we aren't able to provide that kind of information we can invent a sender’s email address (as it can't be checked, it doesn't matter whether it is valid or not). This seems to work well, for example, Gmail doesn't mark these emails as Spam, although it does warn that it couldn't verify the sender’s identity. Note that should the receiver reply to the email, the sender’s email address will only be used if there is no “reply-to” address supplied. So if the email might be replied to, it is important to include a valid “reply-to” address.

Incidentally, this is how a lot of spam is constructed; you are presented with a faked, but reasonable seeming sender’s address, but any reply is sent to the reply-to address which tells the spammer that your email address is active and used by a real person and therefore of value. As a rather trivial example we could enter into a command line:- sendemail -f xxxx@zzzz.com -o reply-to=myemail@mydomainname.com -t test@gmail.com -u 'test of sendemail' -s relay.plus.net I have used a genuine smart host (relay.plus.net) and have specified my invented from-address with the -f parameter, but note that the domain, zzzz.com almost certainly belongs to somebody.

The optional -o reply-to= specifies the real email address where I want any replies to go to – otherwise an attempt will be made to send replies to the zzzz.com mail server (if it exists). The -t parameter specifies a destination address (but don't use test@gmail.com – that must belong to someone); this should be a valid email address that you have access to. The -u parameter specifies the subject field, it is enclosed in quotes because of the presence of special characters (spaces). Finally, I've used the -s parameter to specify my ISP's smart host (relay.plus.net).

However, since I've omitted any reference to the email body, sendemail will attempt to take it from standard input. This can be very useful in a script, but if I enter the above example into the command line, I would be prompted for some body text:- Reading message body from STDIN because the '-m' option was not used. If you are manually typing in a message: - First line must be received within 60 seconds. - End manual input with a CTRL-D on its own line. This isn't usually very convenient so I can specify the message body in two ways, either directly with the -m parameter (example: -m “This is the message body”) or by giving the name of a text file that contains the message body (example: -o message-file=/var/log/user.log).

File attachments are included with the -a parameter, followed by a list of file names separated by spaces or other acceptable delimiters. In a similar way, sending to multiple email addresses is possible by specifying a list of addresses for the -t parameter. Lists of addresses can also be entered for the -cc and -bcc (copy & blind copy) parameters. It should be mentioned that the usual smart host port number is 25, which is the default. However, other values are possible so that the smart host might read relay.plus.net:587 (if port 587 is required). In addition you might need to use the -xu and -xp parameters (for user and password), but hopefully your ISP hasn't encountered sufficient abuse of the facility to make this necessary.

I have only scratched the surface of what this command can do. For a brief summary of what is possible, enter man sendemail For a fuller summary, enter sendemail –help For detailed help, enter one of sendemail –help addressing sendemail –help message sendemail –help misc sendemail –help networking sendemail –help output

issue140/tutoriel2.1546410094.txt.gz · Dernière modification : 2019/01/02 07:21 de d52fr