How to send out emails without using SMTP from server

emailsendmailsmtp

I am trying to write a scheduled job that will send out email with attachments after exporting a set of data from the database to a group of users. The job will be hosted on the server.

I need something that I can run on the server to send out emails. Currently, there is no mail server installed. I don't want to use SMTP because I don't want to store the password to my email account on there (I am not the only one accessing the server).

How else can I send out an email with attachment without using an SMTP account? I have seen some servers able to send out emails without a properly email address, like root@localhost or something like that. Is it possible and how can I set up something like that?

EDIT: I get this idea of sending an email without SMTP because in PHP, for instance, I can send out an email without SMTP. I can also have my own headers in the email to control how the address will look.

Best Answer

SMTP servers do not require authentication. Services like GMail, and my own servers, will require authentication, to send to users outside their domain. If you are sending within the intranet, it is unlikely you will require authentication.

There are minimal SMTP relay servers like SSMTP which are designed to send outgoing email without a full install. Full service servers like Exim, Postfix, and Sendmail can be configured to use a Smarthost (relay) for all outgoing mail. Usually, this would be the corporate mail server, or the ISPs relay server, neither of which is likely to require authentication. Either of these solutions would be appropriate.

Languages like PHP, Perl, and Java have packages which will connect directly to a remote SMTP server. This allows them to send email from hosts which don't have a mail server running. Normally, these would be configured to connect to a relay server as described above.

Ensure the sending address is appropriate. For something like this you may want to use an address in the form noreply@example.com. Use the client's domain in place of host. The client may prefer a different sending address. You may also want a Reply-To: address with the email address of someone who knows about the system, although that may need to be maintained over time.

Related Question