Hi,
To send with SMTP you want to use Email::Sender::Transport::SMTP:
host => 'smtp.gmail.com',
port => 465,
ssl => 1,
sasl_username => 'smtpusername',
sasl_password => 'smtp pass'
});
Then the sendmail() call looks like:
If you want to send BCC, you have to do it like:
I tried it before with just headers, but they were ignored and no CC/BCC's were sent out
I'm still playing with the attachment stuff. Basically, the issue is the structure of the email. It has to send like:
|- multipart/alternative << mail client will choose which of the parts to display
| | text/plain << the mail as plain text
| | text/html << the mail as HTML
|- text/plain << the attachment
But is instead sending all the parts with 1 boundary ID:
|- multipart/alternative << mail client will choose which of the parts to display
| | text/plain << the mail as plain text
| | text/html << the mail as HTML
|- text/plain << the attachment
Its weird - because when I was writing this email code before, it all worked fine in the tests! So looks like its not been behaving properly in some email clients for a while :(
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
To send with SMTP you want to use Email::Sender::Transport::SMTP:
Code:
my $transport = Email::Sender::Transport::SMTP->new({ host => 'smtp.gmail.com',
port => 465,
ssl => 1,
sasl_username => 'smtpusername',
sasl_password => 'smtp pass'
});
Then the sendmail() call looks like:
Code:
sendmail($email->as_string, { transport => $transport } );If you want to send BCC, you have to do it like:
Code:
sendmail($email->as_string, { transport => $transport, to => [$to, $bcc] } );I tried it before with just headers, but they were ignored and no CC/BCC's were sent out
I'm still playing with the attachment stuff. Basically, the issue is the structure of the email. It has to send like:
Code:
multipart/mixed |- multipart/alternative << mail client will choose which of the parts to display
| | text/plain << the mail as plain text
| | text/html << the mail as HTML
|- text/plain << the attachment
But is instead sending all the parts with 1 boundary ID:
Code:
multipart/mixed |- multipart/alternative << mail client will choose which of the parts to display
| | text/plain << the mail as plain text
| | text/html << the mail as HTML
|- text/plain << the attachment
Its weird - because when I was writing this email code before, it all worked fine in the tests! So looks like its not been behaving properly in some email clients for a while :(
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!