I am writing a shell script for Mac which opens an automaker application and sends an email notification that sends an email from default mail The Account Automatator app in Mail.app also adds a text file that is written to the script.
- This is visible in the GUI when sending
- This stole the focus if mail is not the current application
- It should be dependent on establishing mail account in future.
I suspect these shortcomings may come around, send me an email, enter settings, send Address etc. I would like to deploy this script on many computers (10.5 and 10.6) without having to be enabled on the computer, it is possible to do this script, so it will install the 10.5 Base Mac and Open and Open X. And 10.6?
Update: I have received the -bs
option for Sendmail, which I think is what I want, but I am at the loss of specifying settings
In addition, to clarify, the reason I want to specify the SMTP setting is that the mail sent from the local host on the post 25 through the postfix, most will be blocked by the corporate firewall but if I use the server and a specified alternative I think the problem will not run in
since the Mac. & Nbsp; OS & nbsp; X python is included, but considering using a Python script instead of the bash script. I have not tested the part of the send, but it follows.
Python Script
#SettingsSMTP_SERVER = 'mail.myisp.com' SMTP_PORT = 25 SMTP_USERNAME = 'myusername' SMTP_PASSWORD = '$ uper $ ecret' SMTP_FROM = 'sender @ Example.com 'SMTP_TO =' recipient@example.com 'TEXT_FILENAME =' /script/output/my_attachment.txt 'Message = "" This is the message to be sent to the customer. "" # "Import the message now Smtplib, create email from email import encoder, import OS message = email.MIMEMultipart.MIMEMultipart () body = email.MIMEText.MIMEText (message) attachment = email.MIMEBase.MIMEBase ('text', 'plain') attachment.set_payload (open (TEXT_FILENAME) .read ()) attachment.add_header ('content-configuration', 'attachment', file name = os.path.basename ( TEXT_FILENAME)) encoders.encode_base64 (attachment) msg.attach (body) msg.attach (attachment) msg.add_header (, 'sender' SMTP_FROM) msg.add_header ('to', SMTP_TO) # Now message mailer = smtplib. Send SMTP (SMTP_SERVER, SMTP_PORT) # Edit: mailer is already connected # mailer.connect () mailer.login (SMTP_USERNAME, SMTP_PASSWORD) mailer.sendmail (SMTP_FROM, [SMTP_TO], msg.as_string ()) mailer.close ( )
I hope it helps.
No comments:
Post a Comment