<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://t2bwiki.iihe.ac.be/index.php?action=history&amp;feed=atom&amp;title=AutomaticMailSendingFromCluster</id>
	<title>AutomaticMailSendingFromCluster - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://t2bwiki.iihe.ac.be/index.php?action=history&amp;feed=atom&amp;title=AutomaticMailSendingFromCluster"/>
	<link rel="alternate" type="text/html" href="https://t2bwiki.iihe.ac.be/index.php?title=AutomaticMailSendingFromCluster&amp;action=history"/>
	<updated>2026-05-16T07:29:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://t2bwiki.iihe.ac.be/index.php?title=AutomaticMailSendingFromCluster&amp;diff=24&amp;oldid=prev</id>
		<title>Maintenance script: Created page with &quot; === Why sending mail could fail ? === The command/library you use, and the arguments you give to this command/library, are important...  First of all, if you specify an SM...&quot;</title>
		<link rel="alternate" type="text/html" href="https://t2bwiki.iihe.ac.be/index.php?title=AutomaticMailSendingFromCluster&amp;diff=24&amp;oldid=prev"/>
		<updated>2015-08-26T12:28:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; === Why sending mail could fail ? === The command/library you use, and the arguments you give to this command/library, are important...  First of all, if you specify an SM...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
=== Why sending mail could fail ? ===&lt;br /&gt;
The command/library you use, and the arguments you give to this command/library, are important...&lt;br /&gt;
&lt;br /&gt;
First of all, if you specify an SMTP server, you should always use mxin.vub.ac.be (or mxin.ulb.ac.be), and not smtp.vub.ac.be :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#dig @8.8.8.8 MX vub.ac.be&lt;br /&gt;
...&lt;br /&gt;
;; ANSWER SECTION:&lt;br /&gt;
vub.ac.be.		5058	IN	MX	10 mxin.vub.ac.be.&lt;br /&gt;
vub.ac.be.		5058	IN	MX	20 mxin.ulb.ac.be.&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you use commands like &amp;quot;mail&amp;quot;, there is no need to specify the smtp server because this information is obtained from DNS.&lt;br /&gt;
&lt;br /&gt;
Note that using &amp;quot;mail&amp;quot; or &amp;quot;sendmail&amp;quot; commands requires that postfix service is running :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
service postfix start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sending mails from scripts ===&lt;br /&gt;
These examples have been tested from a workernode (private network), and they worked :&lt;br /&gt;
==== Bash ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
success() {&lt;br /&gt;
    echo &amp;quot;Sending mail from node19-1&amp;quot;&lt;br /&gt;
    sendmail -f toto@vub.ac.be -t &amp;lt;&amp;lt;End_of_sendmail&lt;br /&gt;
From: toto@vub.ac.be&lt;br /&gt;
To: toto@vub.ac.be&lt;br /&gt;
Subject: Sending a mail from node19-1&lt;br /&gt;
&lt;br /&gt;
This is just a test message.&lt;br /&gt;
.&lt;br /&gt;
End_of_sendmail&lt;br /&gt;
    sleep 2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
success&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== Perl ====&lt;br /&gt;
This script will work because ccq has been configured as a mail relay :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/perl -W&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
use MIME::Lite;&lt;br /&gt;
use Net::SMTP;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my $txt = &amp;quot;Don&amp;#039;t pannic, it&amp;#039;s just a test run on node19-1.\n&amp;quot;;&lt;br /&gt;
send_mail($txt);&lt;br /&gt;
&lt;br /&gt;
sub send_mail {&lt;br /&gt;
&lt;br /&gt;
    my $from_address = &amp;#039;toto@vub.ac.be&amp;#039;;&lt;br /&gt;
    my $to_address = &amp;#039;toto@vub.ac.be&amp;#039;;&lt;br /&gt;
    my $mail_host = &amp;#039;ccq.wn.iihe.ac.be&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
    my $subject = &amp;quot;[TEST] Keep calm : test mail sent from a node&amp;quot;;&lt;br /&gt;
    my $message_body = shift;&lt;br /&gt;
&lt;br /&gt;
    $msg = MIME::Lite-&amp;gt;new (&lt;br /&gt;
        From =&amp;gt; $from_address,&lt;br /&gt;
        To =&amp;gt; $to_address,&lt;br /&gt;
        Subject =&amp;gt; $subject,&lt;br /&gt;
        Type =&amp;gt;&amp;#039;multipart/mixed&amp;#039;&lt;br /&gt;
        ) or die &amp;quot;Error creating multipart container: $!\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    $msg-&amp;gt;attach (&lt;br /&gt;
        Type =&amp;gt; &amp;#039;TEXT&amp;#039;,&lt;br /&gt;
        Data =&amp;gt; $message_body&lt;br /&gt;
        ) or die &amp;quot;Error adding the text message part: $!\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=1 class=&amp;quot;simple&amp;quot;&lt;br /&gt;
! die &amp;quot;Cannot send email\n&amp;quot;;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
    $msg-&amp;gt;send_by_smtp($mail_host);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note that sending mails this way, using the MIME::Lite perl library, you don&amp;#039;t need postfix service to run.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{TracNotice|{{PAGENAME}}}}&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>