Send Mail from Script

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Kukurykus, Tom, xbytor

Paul MR

Send Mail from Script

Post by Paul MR »

Code: Select allvar mailServer = "mail_Server_name";
var mailAddress = "E-Mail-Address";
var mailTitle = "Results of script";
var mailText = "Script completed at " + new Date();
printText = false; //True print results to Console.

sendmail(mailServer, mailAddress,mailTitle,mailText);

function sendmail(mailServer, mailAddress,mailTitle,mailText){
    var sObj = new Socket();
    if (sObj.open(mailServer+":25")) {
        sObj.writeln("HELO "+mailServer);
        var txt = sObj.read()+"\n";
        sObj.writeln("MAIL From: " + mailAddress);
        txt += sObj.read()+"\n";
        sObj.writeln("RCPT To: "+mailAddress);
        txt += sObj.read()+"\n";
        sObj.writeln("DATA");
        sObj.writeln("From: Photoshop");
        txt += sObj.read()+"\n";
        sObj.writeln("To: "+mailAddress);
        txt += sObj.read()+"\n";
        sObj.writeln("Subject: "+mailTitle);
        txt += sObj.read()+"\n";
        sObj.writeln(mailText);
        txt += sObj.read()+"\n";
        sObj.writeln(".");
        txt += sObj.read()+"\n";
        sObj.writeln("QUIT");
        txt += sObj.read()+"\n";
if(printText) $.writeln(txt);
        sObj.close();
    }
}

Jeremy Knudsen

Send Mail from Script

Post by Jeremy Knudsen »

I'm really curious about this script. What is the correct syntax for the "mail server" and "mail address" strings?

Mike Hale

Send Mail from Script

Post by Mike Hale »

You might want to check out the EMailer panel on Russell Brown's web site. It handles the back end email details and has an option to resize before emailing.

Jeremy Knudsen

Send Mail from Script

Post by Jeremy Knudsen »

Thanks Mike! I'll check it out!