Dear Monks
I have the following script for sending email using the the smtp server from gmail
#!/usr/bin/perl -w
use warnings;
use strict;
use Net::SMTP::TLS;
my $EMAIL_SMTP='smtp.gmail.com';
my $EMAIL_HELLO='me@mydomain.com'; # ?????
my $EMAIL_PORT=587;
my $EMAIL_SENDER = 'mygmail@gmail.com';
my $EMAIL_PASSWORD='s3cr3t';
my $mailer = new Net::SMTP::TLS
(
$EMAIL_SMTP,
Hello => $EMAIL_HELLO,
Port => $EMAIL_PORT,
User => $EMAIL_SENDER,
Password=> $EMAIL_PASSWORD,
);
# this doesn't work
#$mailer->datasend("From: me\@mydomain.com");
#$mailer->datasend("To: you\@yourdomain.com");
#$mailer->datasend("Subject: This is a test");
#$mailer->datasend("\n");
#$mailer->datasend("blahblah\n");
$mailer->mail('me@mydomain.com');
$mailer->to(you@yourdomain.com');
$mailer->data;
$mailer->datasend("Sent thru TLS!");
$mailer->dataend;
$mailer->quit;
Sending mail with this script, I receive email from
mygmail@gmail.com not from
me@mydomain.com. Can this be changed ?
Also, what is the
HELLO good for?
Cheers
LuCa
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.