I want to send an email from my vbscript code, the below code is working properly on my machine, but when I changed my machine, the code is no more able to send email.
There were no errors or problems occurred during run, but no emails were sent/delivered.
Has anyone else faced a problem like this?
Set objMessage = CreateObject("CDO.Message")
With objMessage
.From = SendFrom
.To = SendTo
.Subject = "Subject"
.Textbody = ""
.HTMLBody = "<b>Body</b>"
With .Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP.Gmail.Com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Username"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"
.Update
End With
.Send
End With
First, since you didn't post the entire code, check that your script doesn't contain a line
On Error Resume Next
If it does: remove the line and try again.
If you don't have that line in your script and the script doesn't raise an error and you can telnet mailserver 25 then it's almost certain that the mail server accepted the mail for delivery and the problem is somewhere upstream. Check the mail server logs.
You can verify if the server actually accepts mail like this:
C:\>telnet mailserver 25
220 mailserver ESMTP
HELO clientname
250 mailserver
MAIL FROM:<joe.average#example.com>
250 2.1.0 Ok
RCPT TO:<joe.average#example.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: test
test
.
250 2.0.0 Ok: queued as 4541E2227
QUIT
The line before the QUIT command means that the server accepted the mail. The actual response text may vary depending on which MTA is used, but every MTA will respond with some line like that when it accepts a message.
I would imagine this is a permissions issue or a firewall issue if it is working on your machine but not the production machine.
Carefully look at what is different, is one behind the firewall and other is not?
You need to install CDonts library first. Search on microsoft.com for CDONTS library and install the same.
If you want to send without installation then try the second method. you have to initialize the objects.
In that example i remove h in the link because i can't post links
CDO.MESSAGE
'Script to send an email through QTP nice one
Set oMessage = CreateObject("CDO.Message")
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
oMessage.Configuration.Fields.Item _
("ttp://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
oMessage.Configuration.Fields.Item _
("ttp://schemas.microsoft.com/cdo/configuration/smtpserver") =""
'Server port (typically 25)
oMessage.Configuration.Fields.Item _
("ttp://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = "Test Mail"
oMessage.Sender = ""
oMessage.To =""
'oMessage.CC = ""
'oMessage.BCC = ""
oMessage.TextBody = "Test Mail from QTP"&vbcrlf&"Regards,"&vbcrlf&"Test"
oMessage.Send
Set oMessage = Nothing
Related
I have to send a mail with an attachment from a shell script.
I am trying to do it using mutt as shown here: How do I send a file as an email attachment using Linux command line?
Command:
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient#domain.com
Error:
Error sending message, child exited 127 (Exec error.). Could not send
the message.
I was having the same issue on Ubuntu 18.04 and just like #jono, I only had installed mutt. Installing
sudo apt-get install sendmail
After that, sending mail with the test method or straight through the mutt CLI worked perfectly.
I have encountered this same error today.
I found I only had mutt installed, but once I installed sendmail this error went away. However I then got blocked locally.
So I uninstalled sendmail, and installed postfix this worked..
Now receiving email with attached pdf.
This was on RHEL 7.4 in an enterprise environment. Unsure if results will differ on other versions or environments.
I had this error and had to simply add below to my .muttrc. I'm using Gmail if that matters. This way I'm using someone elses server to send and don't have to install extra junk.
set smtp_pass="secrets"
set smtp_url = "smtps://username#gmail.com#smtp.gmail.com:465/"
set the password generated from this link into this file:
# file: ~/.muttrc
set from="first_name.last_name#gmail.com"
set realname="first_name last_name"
set imap_user="first_name.last_name#gmail.com"
#
# v1.0.1
# check the following google help page:
# http://support.google.com/accounts/bin/answer.py?answer=185833
# that is set here your google application password
set imap_pass="SecretPass!"
#nopeset imap_authenticators="gssapi"
set imap_authenticators="gssapi:cram-md5:login"
set certificate_file="~/.mutt/certificates"
#
# These two lines appear to be needed on some Linux distros, like Arch Linux
#
##REMOTE GMAIL FOLDERS
set folder="imaps://imap.gmail.com:993"
set record="+[Gmail]/Sent Mail"
set spoolfile="imaps://imap.gmail.com:993/INBOX"
set postponed="+[Gmail]/Drafts"
set trash="+[Google Mail]/Trash"
#
###SMTP Settings to sent email
set smtp_url="smtp://first_name.last_name#smtp.gmail.com:587"
#
# v1.0.1
# check the following google help page:
# http://support.google.com/accounts/bin/answer.py?answer=185833
# that is set here your google application password
set smtp_pass="SecretPass!"
#
###LOCAL FOLDERS FOR CACHED HEADERS AND CERTIFICATES
set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies"
set certificate_file =~/.mutt/certificates
#
###SECURING
set move=no #Stop asking to "move read messages to mbox"!
set imap_keepalive=900
#
###Sort by newest conversation first.
set sort=reverse-threads
set sort_aux=last-date-received
#
###Set editor to create new email
set editor='vim'
set ssl_starttls=yes
set ssl_force_tls=yes
Fix for GMail Account Configuration
The following post worked for me: https://www.codyhiar.com/blog/getting-mutt-setup-with-gmail-using-2-factor-auth-on-ubuntu-14-04/
But it was not very clear. The contents of ~/.muttrc that worked for me are as follows (My account has 2-Step verification enabled and I had to generate app password as described in the post):
set imap_user = "<username>#gmail.com"
set imap_pass = "<16-character-app-password>"
set sendmail="/usr/sbin/ssmtp"
set folder="imaps://imap.gmail.com:993"
set spoolfile="imaps://imap.gmail.com/INBOX"
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"
set from = "<username>#gmail.com"
set realname = "<name-used-in-the-gmail-account>"
set smtp_url = "smtp://<username>#smtp.gmail.com:587/"
set smtp_pass="<16-character-app-password>"
set move = no
set imap_keepalive = 900
# Gmail-style keyboard shortcuts
macro index,pager ga "<change-folder>=[Gmail]/All<tab><enter>" "Go to all mail"
macro index,pager gi "<change-folder>=INBOX<enter>" "Go to inbox"
macro index,pager gs "<change-folder>=[Gmail]/Starred<enter>" "Go to starred messages"
macro index,pager gd "<change-folder>=[Gmail]/Drafts<enter>" "Go to drafts"
macro index,pager e "<enter-command>unset trash\n <delete-message>" "Gmail archive message" # different from Gmail, but wanted to keep "y" to show folders.
Replace the following:
<username>: Your gmail username
<16-character-app-password>: You have to generate this
<name-used-in-the-gmail-account>: Your name as per gmail account
Note: Don't change <change-folder>
I am using Postfix as a mail server for my applications. I have setup TLS, DKIM, SPF and TXT records for my mailing domain i.e; mail.xyz.com. This mail domain is pointing to the Postfix server.
The problem is that if I send the email using some mail id of my domain like riky#xyz.com, it works well and the mail gets delivered to any of the mail servers like Gmail, or Yahoo etc. But if I send the mail form other domain mail id like riky#gmail.com the mail appears with a warning signing that the sender is a spammer or sometimes the mail is not delivered and I get a delivery faliure message saying that the mail server is not authorized to send the mail using riky#gmail.com or riky#yahoo.com
I have done some research and learnt about SPF, TXT, DKIM and TLS. I have added all these to the required server but the problem persists still.
Amazon SES, or some other Email APIs has managed this somehow so that we can send the mails from other mail ids and their mail appears in the inbox like this:
xxxx#greymeter.in via amazonses.com
Could anyone help me on this as it has become biggest challenge for us.
My main.cf is:
$# nano /etc/postfix/main.cf
GNU nano 2.0.9 File: /etc/postfix/main.cf
# Global Postfix configuration file. This file lists only a subset
# of all parameters. For the syntax, and for a complete parameter
# list, see the postconf(5) manual page (command: "man 5 postconf").
#
# For common configuration examples, see BASIC_CONFIGURATION_README
# and STANDARD_CONFIGURATION_README. To find these documents, use
# the command "postconf html_directory readme_directory", or go to
# http://www.postfix.org/.
#
# For best results, change no more than 2-3 parameters at a time,
# and test if Postfix still works after every change.
#local_recipient_maps =
# SOFT BOUNCE
#
# The soft_bounce parameter provides a limited safety net for
# testing. When soft_bounce is enabled, mail will remain queued that
# would otherwise bounce. This parameter disables locally-generated
# bounces, and prevents the SMTP server from rejecting mail permanently
# (by changing 5xx replies into 4xx replies). However, soft_bounce
# is no cure for address rewriting mistakes or mail routing mistakes.
#
#soft_bounce = no
# LOCAL PATHNAME INFORMATION
#
# The queue_directory specifies the location of the Postfix queue.
# This is also the root directory of Postfix daemons that run chrooted.
# See the files in examples/chroot-setup for setting up Postfix chroot
# environments on different UNIX systems.
#
queue_directory = /var/spool/postfix
# The command_directory parameter specifies the location of all
# postXXX commands.
#
command_directory = /usr/sbin
# The daemon_directory parameter specifies the location of all Postfix
# daemon programs (i.e. programs listed in the master.cf file). This
# directory must be owned by root.
#
daemon_directory = /usr/libexec/postfix
# The data_directory parameter specifies the location of Postfix-writable
# The data_directory parameter specifies the location of Postfix-writable
# data files (caches, random numbers). This directory must be owned
# by the mail_owner account (see below).
#
data_directory = /var/lib/postfix
# QUEUE AND PROCESS OWNERSHIP
#
# The mail_owner parameter specifies the owner of the Postfix queue
# and of most Postfix daemon processes. Specify the name of a user
# account THAT DOES NOT SHARE ITS USER OR GROUP ID WITH OTHER ACCOUNTS
# AND THAT OWNS NO OTHER FILES OR PROCESSES ON THE SYSTEM. In
# particular, don't specify nobody or daemon. PLEASE USE A DEDICATED
# USER.
#
mail_owner = postfix
# The default_privs parameter specifies the default rights used by
# the local delivery agent for delivery to external file or command.
# These rights are used in the absence of a recipient user context.
# DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER.
#
#default_privs = nobody
# INTERNET HOST AND DOMAIN NAMES
#
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
myhostname = mail.xyz.com
#myhostname = virtual.domain.tld
# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain =xyz.com
# SENDING MAIL
#
# The myorigin parameter specifies the domain that locally-posted
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites. If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user#that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no #domain part.
#
#myorigin = $myhostname
myorigin = $mydomain
# RECEIVING MAIL
# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on. By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user#[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost
# Enable IPv4, and IPv6 if supported
inet_protocols = all
# The proxy_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on by way of a
# proxy or network address translation unit. This setting extends
# the address list specified with the inet_interfaces parameter.
#
# You must specify your proxy/NAT addresses when your system is a
# backup MX host for other domains, otherwise mail delivery loops
# will happen when the primary MX host is down.
#
proxy_interfaces = 10.2.11.292, 120.18.12.73, 18.75.58.218
#proxy_interfaces = 1.2.3.4
unknown_local_recipient_reject_code = 550
#relay_domains = $mydestination
relay_domains =
#smtpd_use_tls = yes
smtpd_recipient_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination
#alias_maps = dbm:/etc/aliases
alias_maps = hash:/etc/aliases
#alias_maps = hash:/etc/aliases, nis:mail.aliases
#alias_maps = netinfo:/aliases
#alias_database = dbm:/etc/aliases
#alias_database = dbm:/etc/mail/aliases
alias_database = hash:/etc/aliases
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
smtpd_banner = mail.xyz.com ESMTP
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
# html_directory: The location of the Postfix HTML documentation.
#
html_directory = no
#
sample_directory = /usr/share/doc/postfix-2.6.6/samples
# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
#For TLS set up For xyz.com
# TLS parameters
smtpd_tls_CAfile = /etc/postfix/tls/xyz_com.crt
smtpd_tls_cert_file = /etc/postfix/tls/xyz_com.crt
smtpd_tls_key_file = /etc/postfix/tls/xyz_com.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_CAfile = /etc/postfix/tls/xyz_com.crt
smtp_tls_cert_file = /etc/postfix/tls/xyz_com.crt
smtp_tls_key_file = /etc/postfix/tls/xyz_com.key
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
smtp_use_tls = yes
smtpd_tls_received_header = yes
smtpd_tls_ask_ccert = yes
smtpd_tls_loglevel = 1
tls_random_source = dev:/dev/urandom
# TLS end
# Added 16 April,2015
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
# Added for DKIM
smtpd_milters = inet:127.0.0.1:8891
non_smtpd_milters = $smtpd_milters
milter_default_action = accept
#milter_protocol = 2
An early response will be highly appreciated.
Thanks
Put simply, you can't do what you're trying to do.
You're trying to say that your server is authorized to send email as a Yahoo or Gmail address, without being so authorized by Yahoo or Google. If this were allowed, then anyone could stand up an SMTP server and send email masquerading as any Yahoo or Gmail address (or for that matter, any other email address). That's called phishing and it's a very bad thing.
Amazon SES can (sort of) get away with this, as you note above. But even that hole is closing, as more of the large senders adopt DMARC to block this kind of phishing email. With a DMARC p=reject policy in place, even the Amazon SES email gets bounced. The big email service providers (like Amazon SES) are currently in the process of adjusting to these anti-phishing standards.
Your best option is to send email exclusively from domains that you control and treat this as a limitation of the technology.
I have followed this link and here is my php code. My issue is that I have tried so many times with this and didn't receive any emails. Could you please point out what went wrong? Thank you
http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/
if($result)
{
$to = $email;
$subject = "Your comfirmation email";
$header = "from: your name <your email>";
$message = "Thank you for registering with us. You can now login to your account";
if(mail($to, $subject,$header,$message))
{
echo 'Your Confirmation Email Has Been Sent To Your Email Address.
Click here to Login';
}
else
{
echo 'Cannot send Confirmation link to your e-mail address.
Click here to Register';
}
}
Do you have a mail server configured on your system?
Windows does not come with a mail server like *nix. The simple answer is to use a library like phpMailer, which allows you to use a gmail /yahoo /etc mail account to send you email.
I've just upgraded from XAMPP 1.7.3 to 1.8.0, this included quite a few changes (PHP 5.4 etc) as I went through the reinstallation of my dev-environment.
Anyways, everything works now, except for Sendmail.
Before, you had a configuration in sendmail.ini like this:
#defaults
logfile "C:\XAMPP\sendmail\sendmail.log"
## A freemail service example
account Hotmail
tls on
tls_certcheck off
host smtp.live.com
from [exampleuser]#testmail.loc
auth on
user [exampleuser]#hotmail.com
password [examplepassword]
# Set a default account
account default : Hotmail
Plus some values in php.ini:
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
SMTP = localhost
smtp_port = 25
Now it all looks a lot different (and the old config wouldn't work), an example:
http://pastebin.com/M83bNmJw
A little php mail script:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$to = "someone#hotmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
Message delivery failed...
I guess I'm too stupid to change the correct things, it just won't work, plus I barely get an error in my log-files, so I don't even know where to start.
#GMAIL mit XAMPP 1.8.1 und sendmail
[CODE]
[sendmail]
; HOTMAIL
smtp_server=smtp.gmail.com
smtp_port=25
smtp_ssl=tls
tls_certcheck off
error_logfile=error.log
debug_logfile=debug.log
auth_username= xxxx.xxxx#gmail.com
auth_password=xxxxxxx
this settings in php.ini
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = smtp.gmail.com
; smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = xxxx.xxxx#gmail.com
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"C:\sendmail\sendmail.exe\" -t"
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off
; Log all mail() calls including the full path of the script, line #, to address and headers
mail.log = "C:\xampp\php\logs\php_mail.log"
I see that in 1.8.0, the default will send mail through mailtodisk.exe. You have enabled it in your PHP config file, but have you disabled mailtodisk.exe?
In addition, you'll need to ensure that smtp_server in sendmail.ini is set to localhost.
I just found this solution myself, and all mail sent using PHP works.
My xampp is 1.8.2 with window 8.1
In php.ini
smtp_port = 587
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
mail.add_x_header=Off
In sendmail.ini
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=xxaayy#gmail.com
auth_password=kskcmhlrjr
pop3_server=
pop3_username=
pop3_password=
force_sender=xxaayy#gmail.com
force_recipient=
hostname=
To account gmail "auth_password" you need create new password "Your application-specific passwords", check [here][1]
then follow these steps:
The problem is that sendmail has to be run as an administrator. This is the solution to help any one on my situation.
Right click on sendmail.exe
Properties
Compatibility
Change the configuration for all users
Execute as Windows XP SP 3
Execute as adminitrator
test email
$to = "aaaaaaa#domain.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$headers = "From: xxaayy#gmail.com" . "\r\n";
if (mail($to, $subject, $body, $headers)) {
echo ("Message successfully sent!");
} else {
echo ("Message delivery failed...");
}
I've found a working example, it works like a charm now
http://blog.joergboesche.de/xampp-sendmail-php-mailversand-fuer-windows-konfigurieren#xampp_180_sendmail
I need a tiny Windows script to send a 1 line email to Gmail accounts. I have tried many utilities that claim to do this such as BLAT, but none work. The script will be executed inside a batch file if certain conditions are met. Script can be in Perl, Python, VBScript, Java, it does not matter as long as it executes from a batch file. Please only answer if you have tried your solution by sending an email to a Gmail account from either a Gmail, Hotmail or Yahoo email account. The account I am using by default is Gmail, so I am sending from a Gmail account to a Gmail account.
Blat lets you send e-mails directly from batch files:
blat.exe - -f from#example.com -to to#gmail.com -s Subject -body "Text body" ^
-server smtp.example.com:25 -u username -pw password
But it seems that Blat doesn't support SSL, so to make it work with the Gmail you need an additional tool called Stunnel (see here and here).
Anyway, you should be able to send an e-mail via GMail from VBScript using the Collaboration Data Objects (CDO) COM API:
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf
' E-mail properties
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "from#gmail.com" ' or "Sender Name <from#gmail.com>"
oMsg.To = "to#gmail.com" ' or "Recipient Name <to#gmail.com>"
oMsg.Subject = "Subject"
oMsg.TextBody = "Text body"
' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp.gmail.com"
oConf.Fields(schema & "smtpserverport") = 465
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic
oConf.Fields(schema & "smtpusessl") = True
oConf.Fields(schema & "sendusername") = "from#gmail.com"
oConf.Fields(schema & "sendpassword") = "sender_password"
oConf.Fields.Update
oMsg.Send
Edit: Added the lacking sendusing parameter so it should work fine now.
See here for more CDO examples.
Have a look at this script on perlmonks which details IMAP access on a GMail account. The post covers everything you need to login into a GMail account through Perl.
Alternatively you could try the Mail::Webmail::Gmail module in CPAN. From the looks of it the module lets you skip most of the intricate details concerning connecting and authenticating with the mail server leaving you with something as simple as -
my $gmail = Mail::Webmail::Gmail->new( username => 'username', password => 'password', );
$gmail->send_message( to => 'user#domain.com', subject => 'Test Message', msgbody => 'This is a test.' );
There's also Email::Send::Gmail in case you need to 'only' send emails from a Gmail account.
#!c:/Python/python.exe -u
import libgmail
ga = libgmail.GmailAccount("username#gmail.com", "password")
ga.login()
msg=libgmail.GmailComposedMessage("friend#gmail.com", "SubjectHere", "BodyHere")
ga.sendMessage(msg)
That should run on Windows using python. Make sure you change the shebang at the top to point to your python installation. Other than that, just enter your name and password, along with the email you want to send.
If you need just to send to GMail using some SMTP, use MIME::Lite Perl module in SMTP mode - I use it to send notifications to my GMail account.
In Linux (I'm not sure what environment you're on) you can use mail:
some_command| mail foo#gmail.com bar#gmail.com -s "subject"