help needed for Xmail OSAX with Gmail

Hi,

I’m trying to use the Xmail OSAX but I never receive any emails with this script. The Xmail dictionary is here. Has anyone been able to get it to work with Gmail? I tried multiple settings but all to no avail.

property myTo : "MyName@gmail.com"
property myFrom : "MyName@gmail.com"
property theSubject : "test"
property thebody : "test"
property theUsername : "MyName@gmail.com"
property thePassword : "MyPassWord"
property theServer : "smtp.gmail.com"
property theAuth : "login" -- or plain/crammd5/anonymous/auto
property UseSSL : true
property SSL_Verification : "verify none" -- alternative setting is "verify none"

sendMail()

on sendMail()
	try
		send mail to myTo from myFrom subject theSubject body thebody SMTP server theServer username theUsername password thePassword authentication theAuth ssl UseSSL ssl verification SSL_Verification
	on error msg
		display dialog "ERROR: " & msg
	end try
end sendMail

Hi Stadsman!

After playing around, checking the dictionary (multiple times LOL), and reading Google’s article on using a email client with gmail I have a working script!

set myTo to {"MyName@gmail.com"}
set myFrom to "MyName@gmail.com"
set theSubject to "test"
set thebody to "test"
set theUsername to "MyName@gmail.com"
set thePassword to "MyPassWord"
set theServer to "smtp.gmail.com"
set UseSSL to true
set thePort to 587

sendMail(myTo, myFrom, theSubject, thebody, theUsername, thePassword, theServer, UseSSL, thePort)

on sendMail(myTo, myFrom, theSubject, thebody, theUsername, thePassword, theServer, UseSSL, thePort)
	try
		send mail to myTo from myFrom subject theSubject body thebody SMTP server theServer username theUsername password thePassword authentication login ssl UseSSL ssl verification verify none port thePort
	on error msg
		display dialog "ERROR: " & msg
	end try
end sendMail

So as you can see I made a few small differences:

The too field has to be a list of text.
The outgoing port has to be changed from 25 to 587
And the authentication type and ssl verification type have to be manually specified. Looking at the dictionary shows they are not of type text, but actually keywords in their own right.

Finally I don’t like using properties so I am passing local scope variables to the handler. I did test it though using properties and it worked just fine.

Hope that helps!

Acctually one last thing, make sure in the gmail account under setting you enable POP access. :smiley:

GREAT!!!

I am so grateful!

:D:D:D

I was struggling with it for hours!!!

Happy to be of assitance =)

For those interested in trying XMail as well, here is the link.

My company blocks SMTP access because of outgoing spam. I got an exemption for my IP, but the SMTP server only has access to its IP. This is based on the sample script from XMail.

set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","

set |to| to "user@domain.com"
set |from| to "user@domain.com"
set smtpServer to "10.100.10.100:10"

set theSubject to "Plain text email -- test"
set thebody to "This is a test!

--> Now, compose the source and send the email...
set rawSource to "Date: " & (do shell script "date '+%a, %e %b %Y %H:%M:%S %z'") & return & ¬
	"To: <" & |to| & ">" & return & ¬
	"From: <" & |from| & ">" & return & ¬
	"Subject: " & theSubject & return & ¬
	"Mime-Version: 1.0
X-Mailer: XMail
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: quoted-printable" & return & ¬
	thebody

try
	send raw mail to |to| from |from| raw source rawSource SMTP server smtpServer
on error number -2753 --> you don't need authentication and such variables are undefined...
	send raw mail to |to| from |from| raw source rawSource SMTP server smtpServer
end try
set AppleScript's text item delimiters to oldTI

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger4
Browser: Firefox 3.0
Operating System: Mac OS X (10.4)