473,418 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Automating sendmail auto adding e-mail adress

14
Help Please

I am very new to the Perl game and need some help

I have a Perl application which works fine and can output some plain text information that I need to send to selected users via e-mail.

The e-mail address are under the $addr and the information that I whish to put in the e-mail message are held in $msg

I have installed and have working Sendmail the script that I have come up with so far is

Expand|Select|Wrap|Line Numbers
  1. sub send_mail
  2. {
  3.     my $addr = shift;
  4.     my $msg = shift;'
  5.     my %mail;
  6.     my $body;
  7.  
  8.     # start a new mail message
  9.  
  10.     # setup the headers
  11.     %mail = (
  12.         To => 'fred@me.net',
  13.         From => 'bob@me.net',
  14.         subject =>' Warning information',
  15.         Message =>'This mail message was generated automatically 
  16. and has been sent to you because you have requested certain this information via email’,
  17.     );
  18.  
  19.     # close the mail object (causes it to be sent)
  20. sendmail(%mail) or die $Mail::Sendmail::error;
  21.  
  22.     print "OK. Log says:\n", $Mail::Sendmail::log;
  23.  
This sends an e-mail as shown above fine

How do I get the $addr tag to automatically put the recipients email address into the to field?

Secondly how do I get the $msg tag to automatically put its information into the e-mail message.

This will I guess be either very easy or am I asking the impossible?
I have now spent severally days searching the net and trying to work this out so any help would be most appreciated
May 9 '07 #1
6 1859
KevinADC
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. $msg  = "something";
  2. @list = (a list of email recipients);
  3.  
  4. foreach $person (@list) {
  5.    send_mail($person,$msg)
  6. }
May 9 '07 #2
Guern1
14
Hi KevinADC

Thanks for the reply

Being new at Perl I don’t think I fully explained myself.

The $addr has the e-maill address that I want to use what I cant see is how to put the value/ email address that $addr has in to the e-mail to field.

Thanks
May 9 '07 #3
KevinADC
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. sub send_mail
  2. {
  3.     my $addr = shift;
  4.     my $msg = shift;'
  5.     my %mail;
  6.     my $body;
  7.  
  8.     # start a new mail message
  9.  
  10.     # setup the headers
  11.     %mail = (
  12.         To => $addr,
  13.         From => 'bob@me.net',
  14.         subject =>' Warning information',
  15.         Message =>$msg,
  16.     );
  17.  
  18.     # close the mail object (causes it to be sent)
  19. sendmail(%mail) or die $Mail::Sendmail::error;
  20.  
  21.     print "OK. Log says:\n", $Mail::Sendmail::log;
May 9 '07 #4
Guern1
14
Hi

Thanks for all the help
I am almost there now all the right information is now sent in the email
The only problem now is the formatting of the body of the email
as you can see below all the lines of text are in the wrong order

Subject: Warning information

:
Information 10-May-2007 2320z country: hungary-Ha zone: 15 baa->dx: 1603km rule: 6
: conditions or rare stations be reported by email.
Date: Thu, 10 May 2007 23:20:59 +0000
Content-Transfer-Encoding: 8bit
To: me@cs.net
and has been sent to you because you have requested certain propagation
: This mail message was generated automatically by software
Mime-Version: 1.0


The message should read

This mail message was generated automatically by software
and has been sent to you because you have requested certain propagation
conditions or rare stations be reported by email.

Information 10-May-2007 2320z country: hungary-Ha zone: 15 dxg->dx: 1603km rule: 6

I am so close now to getting this working I have spent the last day reading and trying sendmail settings with limited success.

Also

Date: Thu, 10 May 2007 23:20:59 +0000
Content-Transfer-Encoding: 8bit
To: me@cw.net
Also get put in the email

Thanks for any help

Keith
May 10 '07 #5
KevinADC
4,059 Expert 2GB
Message =>"whatever you want here\n$msg";
May 11 '07 #6
Guern1
14
Many thanks for all your help

All is now working as I want it to

I have learnt a lot along the way

Many thanks again

Keith
May 12 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jim | last post by:
Hello, I am having a problem w/SendMail reporting: " No recipient addresses found in header". Funny thing is though, I properly recieve the email message. Thanks for your help. -jim
2
by: janet | last post by:
HI, I had a question on auto-commit in DB2 EEE V8 on AIX V5. Here is my example.. there are two script A.sh , B.SQL A.sh is following:
7
by: xzzy | last post by:
I need to automate a report in a different database (and thank yous to Terry Kreft for pointing me in the right direction). below is the code with the one line that does not work, marked: 'Does...
1
by: Dave N | last post by:
I have a list box with the directory path of an OLE object and I want to automate adding the object to my tblEmbededObjectst table when a Save button is pressed. I can import them manually but con...
3
by: Chris | last post by:
Before I started to create table, etc to track unique form field record number assigments I thought I'd check to see if there is now a better way to do this in .NET. I have a parent form (table)...
1
by: Shelly | last post by:
I want to be able to create a sendmail account by commands sent from a web page. I am using php. After everything is done, I want to enter his info into the database (easy) and create this...
5
by: Phil Latio | last post by:
I have 2 virtually identical tables and wish to move data between them. Basically one table is called "live_table" and the other is named "suspended_table" and the only difference is that the...
1
by: Liam.M | last post by:
HEY GUYS, need some urgent help here....I am querying my database based on a DueDate field...and want to send an automated email to anyone that falls within two months PRIOR to this "DueDate",...
15
by: Neo | last post by:
Hello All, I found that ASP.net website only accepts code withing site directory. This creates big hurdle in shairng code. How to share code between two websites, like the way share between two...
3
by: swangdb | last post by:
I have a Sun Server running Solaris 10 and Sendmail 8.13.7. I have Majordomo and Listproc installed on this server and they work. I have several production majordomo and listproc mailing lists...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.