Jump to page: 1 2
Thread overview
SMTP Mail
Aug 22, 2017
Vino.B
Aug 25, 2017
Adam D. Ruppe
Apr 08
Vino
Apr 09
Vino
Apr 09
Vino.B
Apr 10
Vino
Apr 10
Vino
Apr 12
Vino
August 22, 2017
Hi All,

  Request your help on sending Mails, I am able to receive mails with empty body the line "smtp.message ="Example Message" doesn't seem to be working and also please let me know how do i send a file as a attachment in a email.

import std.net.curl;
void main ()
{
auto smtp = SMTP("smtp://server.com");
smtp.mailTo = ["xxx@xxx.com"];
smtp.mailFrom = "xxx@xxx.com";
smtp.message = "Example Message";
smtp.perform();
}

From,
Vino.B
August 25, 2017
On Tuesday, 22 August 2017 at 12:52:24 UTC, Vino.B wrote:
>   Request your help on sending Mails, I am able to receive mails with empty body the line "smtp.message ="Example Message" doesn't seem to be working and also please let me know how do i send a file as a attachment in a email.

The message there needs to be the complete message, including headers. The SMTP struct is pretty low-level.

My email.d (plus its dependencies, characterencodings.d, dom.d, and htmltotext.d) has the code to form a full message. It isn't very documented though.

https://github.com/adamdruppe/arsd


auto message = new EmailMessage();
message.to ~= "some@email";
message.subject = "Subject"
message.setTextBody("hi");
message.send(RelayInfo("smtp://whatever", "user", "pass"));
April 08
On Friday, 25 August 2017 at 02:13:42 UTC, Adam D. Ruppe wrote:
> On Tuesday, 22 August 2017 at 12:52:24 UTC, Vino.B wrote:
>>   Request your help on sending Mails, I am able to receive mails with empty body the line "smtp.message ="Example Message" doesn't seem to be working and also please let me know how do i send a file as a attachment in a email.
>
> The message there needs to be the complete message, including headers. The SMTP struct is pretty low-level.
>
> My email.d (plus its dependencies, characterencodings.d, dom.d, and htmltotext.d) has the code to form a full message. It isn't very documented though.
>
> https://github.com/adamdruppe/arsd
>
>
> auto message = new EmailMessage();
> message.to ~= "some@email";
> message.subject = "Subject"
> message.setTextBody("hi");
> message.send(RelayInfo("smtp://whatever", "user", "pass"));

Hi Adam,

  I am trying your email.d programming, and i am getting the below errors, can you please help me, i just used these programs (characterencodings.d, color.d, dom.d, htmltotext.d, email.d)

Program
import arsd.email;
void main() {

auto message = new EmailMessage();
message.to ~= "vino@xxx.com";
message.subject = "Test";
message.setHtmlBody("<b>1.Line 1</b><b>2.Line 2</b><b>3.Line 3</b>");
message.addAttachment("text/txt", "C:\\Temp\\test.log", "Text");
message.send(RelayInfo("smtp://smtp.xxxx.com"));
}

Error
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
C:\Users\-TSK-X~1\AppData\Local\Temp\6\.rdmd\rdmd-dmail.d-4C543ACF04BF46D1398435D9500B3B70\objs\dmai
l.exe.obj(dmail.exe)
 Error 42: Symbol Undefined __D6object__T14__switch_errorZQrFNaNbNiNfAyakZv
C:\Users\-TSK-X~1\AppData\Local\Temp\6\.rdmd\rdmd-dmail.d-4C543ACF04BF46D1398435D9500B3B70\objs\dmai
l.exe.obj(dmail.exe)
 Error 42: Symbol Undefined __D4arsd10htmltotext10htmlToTextFAyabiZQg
C:\Users\-TSK-X~1\AppData\Local\Temp\6\.rdmd\rdmd-dmail.d-4C543ACF04BF46D1398435D9500B3B70\objs\dmai
l.exe.obj(dmail.exe)
 Error 42: Symbol Undefined __D4arsd10htmltotext12__ModuleInfoZ
Error: linker exited with status 3

From,
Vino.B
April 09
On Sunday, 8 April 2018 at 15:45:48 UTC, Vino wrote:
> On Friday, 25 August 2017 at 02:13:42 UTC, Adam D. Ruppe wrote:
>> [...]
>
> Hi Adam,
>
>   I am trying your email.d programming, and i am getting the below errors, can you please help me, i just used these programs (characterencodings.d, color.d, dom.d, htmltotext.d, email.d)
>
> [...]

Hi All,

 Any help is much appreciated.

From,
Vino.B
April 09
On Sunday, 8 April 2018 at 15:45:48 UTC, Vino wrote:
>   I am trying your email.d programming, and i am getting the below errors, can you please help me, i just used these programs (characterencodings.d, color.d, dom.d, htmltotext.d, email.d)

What is your build command?

It looks like a module is just missing in the build.

If you are using rdmd, what is your directory layout too.

(I don't work Sundays btw so that's why I am so slow to respond.)
April 09
On Monday, 9 April 2018 at 13:02:06 UTC, Adam D. Ruppe wrote:
> On Sunday, 8 April 2018 at 15:45:48 UTC, Vino wrote:
>>   I am trying your email.d programming, and i am getting the below errors, can you please help me, i just used these programs (characterencodings.d, color.d, dom.d, htmltotext.d, email.d)
>
> What is your build command?
>
> It looks like a module is just missing in the build.
>
> If you are using rdmd, what is your directory layout too.
>
> (I don't work Sundays btw so that's why I am so slow to respond.)

Hi Adam,

Thank you very much, I copied your folder arsd under the phobes folder in c:\D\... and the program was placed on my desktop and tried to execute it from the desktop via rdmd.

From,
Vino.B

April 09
On Monday, 9 April 2018 at 15:38:55 UTC, Vino.B wrote:
> Thank you very much, I copied your folder arsd under the phobes folder in c:\D\... and the program was placed on my desktop and tried to execute it from the desktop via rdmd.


I don't think rdmd is seeing the dependency on htmltotext.d. Try importing it explicitly from your main:

import arsd.email;
import arsd.htmltotext;

/* the rest of your code */


Just that way rdmd will find it easier.
April 10
On Monday, 9 April 2018 at 19:19:53 UTC, Adam D. Ruppe wrote:
> On Monday, 9 April 2018 at 15:38:55 UTC, Vino.B wrote:
>> Thank you very much, I copied your folder arsd under the phobes folder in c:\D\... and the program was placed on my desktop and tried to execute it from the desktop via rdmd.
>
>
> I don't think rdmd is seeing the dependency on htmltotext.d. Try importing it explicitly from your main:
>
> import arsd.email;
> import arsd.htmltotext;
>
> /* the rest of your code */
>
>
> Just that way rdmd will find it easier.

Hi Adam,

 Now the program works, but the attachment does not work as expected,

message.addAttachment("text/plain", "C:\\Temp\\Test\Test1.txt", "Test");


It takes the full path as file name eg: If the attachment file resides on the path C:\Temp\Test\Test1.txt" the attachment name file name that we receive is as "CTempTestTest1.txt" and also it does not attached the real file, instead the content of the file is "Test"

We Tried the below

message.addAttachment("text/plain", "Test1.txt", "C:\\Temp\\Test\Test1.txt");

After the above change the attachment file name is "Test1.txt" with the content "C:\Temp\Test\Test1.txt"

The orignal content of the file is "Hi This is Test Attachment".

From,
Vino.B
April 10
On Tuesday, 10 April 2018 at 11:09:56 UTC, Vino wrote:
>  Now the program works, but the attachment does not work as expected,
>
> message.addAttachment("text/plain", "C:\\Temp\\Test\Test1.txt", "Test");

What did you expect that "Test" argument to do if it was going to read the file as the content? I guess I should change the documents on this. The way it works is the filename argument is just what is seen in the email as a suggestion name for the user to download the attachment, and the content argument is what is what's inside that attachment.

Since the attachment name just suggests a name, and the user decides where to put it, it should NOT have a path name.

So try this instead:


addAttachment("text/plain", "Test1.txt", std.file.read("C:\Temp\Test\Test1.txt"));


so the name argument is JUST the name to suggest to the user, then the content argument gives the content of your file to attach - which here is read from the file on disk via the phobos std.file read function.
April 10
On Tuesday, 10 April 2018 at 13:51:02 UTC, Adam D. Ruppe wrote:
> On Tuesday, 10 April 2018 at 11:09:56 UTC, Vino wrote:
>>  Now the program works, but the attachment does not work as expected,
>>
>> message.addAttachment("text/plain", "C:\\Temp\\Test\Test1.txt", "Test");
>
> What did you expect that "Test" argument to do if it was going to read the file as the content? I guess I should change the documents on this. The way it works is the filename argument is just what is seen in the email as a suggestion name for the user to download the attachment, and the content argument is what is what's inside that attachment.
>
> Since the attachment name just suggests a name, and the user decides where to put it, it should NOT have a path name.
>
> So try this instead:
>
>
> addAttachment("text/plain", "Test1.txt", std.file.read("C:\Temp\Test\Test1.txt"));
>
>
> so the name argument is JUST the name to suggest to the user, then the content argument gives the content of your file to attach - which here is read from the file on disk via the phobos std.file read function.

Hi Adam,

  Thank you very much, the program now works, but i need to make some adjustment, if possible can you please help me on this.

The variable "to" is of type string[] but we need it as Array!string
The variable "Subject" but we need it as Array!string.

From,
Vino.B


« First   ‹ Prev
1 2