Results 1 to 8 of 8
  1. #1
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed

    [Help]Sending Email

    How do i send emails with c++. I google and found out about POP3 and SMTP but idk how to use it. Your help is appreciated. Thanks.

  2. #2
    Melodia's Avatar
    Join Date
    Dec 2009
    Gender
    female
    Posts
    2,608
    Reputation
    276
    Thanks
    1,662
    My Mood
    Dead
    To send e-Mails with Code, Start by knowing how Mail Servers/Protocols Works =).

    POP(3)/IMAP/SMTP = Protocols.

    Edit~

    Okay ; I admit my answer wasn't convenient, But You give me that feeling ; Let me explain myself.

    I often see you post thingys about new thingies and never you trying to go far/further in something, Only ask for basic things you don't know and overview without trying to understand, And In my opinion of coding this is not really a good thing to do if you want to learn instead of Paste...
    Last edited by Melodia; 09-24-2010 at 09:03 PM.
    Love You All~

  3. The Following 3 Users Say Thank You to Melodia For This Useful Post:

    258456 (09-24-2010),NextGen1 (09-24-2010),Void (09-24-2010)

  4. #3
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    no problem melodia i will search those things on google and notify you about my progress. xD

  5. #4
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    Quote Originally Posted by 258456 View Post
    no problem melodia i will search those things on google and notify you about my progress. xD
    Ok can't really find any good tutorials so can someone exlain it? All I know is that it involves windsock programming

  6. #5
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    POP3 is for incoming messages.
    SMTP is for outgoing messages.

    [php]#include<iostream>
    #include <syspes.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <netdb.h>
    #include <stdio.h>
    using namespace std;
    #define HELO "HELO 192.168.1.1\r\n"
    #define DATA "DATA\r\n"
    #define QUIT "QUIT\r\n"

    //#define h_addr h_addr_list[0]
    //FILE *fin;
    int sock;
    struct sockaddr_in server;
    struct hostent *hp, *gethostbyname();
    char buf[BUFSIZ+1];
    int len;
    char *host_id="192.168.1.10";
    char *from_id="rameshgoli@domain.com";
    char *to_id="rameshgoli@domain.com";
    char *sub="testmail\r\n";
    char wkstr[100]="hello how r u\r\n";

    /*=====Send a string to the socket=====*/

    void send_socket(char *s)
    {
    write(sock,s,strlen(s));
    write(1,s,strlen(s));
    //printf("Client:%s\n",s);
    }

    //=====Read a string from the socket=====*/

    void read_socket()
    {
    len = read(sock,buf,BUFSIZ);
    write(1,buf,len);
    //printf("Server:%s\n",buf);
    }

    /*=====MAIN=====*/
    int main(int argc, char* argv[])
    {

    /*=====Create Socket=====*/
    sock = socket(AF_INET, SOCK_STREAM, 0);
    if (sock==-1)
    {
    perror("opening stream socket");
    exit(1);
    }
    else
    cout << "socket created\n";
    /*=====Verify host=====*/
    server.sin_family = AF_INET;
    hp = gethostbyname(host_id);
    if (hp==(struct hostent *) 0)
    {
    fprintf(stderr, "%s: unknown host\n", host_id);
    exit(2);
    }

    /*=====Connect to port 25 on remote host=====*/
    memcpy((char *) &server.sin_addr, (char *) hp->h_addr, hp->h_length);
    server.sin_port=htons(25); /* SMTP PORT */
    if (connect(sock, (struct sockaddr *) &server, sizeof server)==-1)
    {
    perror("connecting stream socket");
    exit(1);
    }
    else
    cout << "Connected\n";
    /*=====Write some data then read some =====*/
    read_socket(); /* SMTP Server logon string */
    send_socket(HELO); /* introduce ourselves */
    read_socket(); /*Read reply */
    send_socket("MAIL FROM: ");
    send_socket(from_id);
    send_socket("\r\n");
    read_socket(); /* Sender OK */
    send_socket("VRFY ");
    send_socket(from_id);
    send_socket("\r\n");
    read_socket(); // Sender OK */
    send_socket("RCPT TO: "); /*Mail to*/
    send_socket(to_id);
    send_socket("\r\n");
    read_socket(); // Recipient OK*/
    send_socket(DATA);// body to follow*/
    send_socket("Subject: ");
    send_socket(sub);
    read_socket(); // Recipient OK*/
    send_socket(wkstr);
    send_socket(".\r\n");
    read_socket();
    send_socket(QUIT); /* quit */
    read_socket(); // log off */

    //=====Close socket and finish=====*/
    close(sock);
    exit(0);[/php]

  7. The Following User Says Thank You to freedompeace For This Useful Post:

    258456 (09-29-2010)

  8. #6
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    this is the error i get,

    fatal error C1083: Cannot open include file: 'netinet/in.h': No such file or directory
    how do i fix that, I know what it means i just don't know what to do cuz if i take it out there will be many more errors, so was it misspelled or something?

  9. #7
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    well thanks for everybody's help? lol

  10. #8
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    google the file and dl it >.<
    Ah we-a blaze the fyah, make it bun dem!

Similar Threads

  1. [HELP] Sends Email
    By FUKO in forum Visual Basic Programming
    Replies: 19
    Last Post: 04-06-2011, 08:08 PM
  2. [HELP] Sending Pictures
    By ViittO in forum Visual Basic Programming
    Replies: 4
    Last Post: 02-13-2010, 09:20 PM
  3. Help on sending emails
    By zmansquared in forum Visual Basic Programming
    Replies: 4
    Last Post: 02-13-2010, 01:34 PM
  4. [HELP]Send random keys?
    By Pixie in forum Visual Basic Programming
    Replies: 26
    Last Post: 10-25-2009, 11:54 AM
  5. Need Help Sending a Virus
    By I_Cheat in forum General Hacking
    Replies: 1
    Last Post: 10-23-2009, 04:00 PM