void MainWindow::sendMail()
{
    Smtp* smtp = new Smtp(ui->uname->text(), ui->paswd->text(), ui->server->text(), ui->port->text().toInt());
    connect(smtp, SIGNAL(status(QString)), this, SLOT(mailSent(QString)));


    smtp->sendMail(ui->uname->text(), ui->rcpt->text() , ui->subject->text(),ui->msg->toPlainText());
}
예제 #2
0
void Email::pdfCreated()
{
    Smtp* smtp = new Smtp(this);
    connect(smtp, SIGNAL(mailSent()), this, SLOT(mailSent()));
    connect(smtp, SIGNAL(error(QString)), this, SLOT(mailError(QString)));
    connect(smtp, SIGNAL(finished()), smtp, SLOT(deleteLater()));
    smtp->sendFile(*sendSettings, *emailSettings, tempFile->fileName());
}
void MainWindow::sendMail()
{
    Smtp* smtp = new Smtp(settings.value("uname").toString(), settings.value("pswd").toString(),
                          settings.value("Server").toString(), settings.value("port").toInt());
    connect(smtp, SIGNAL(status(QString)), this, SLOT(mailSent(QString)));

    if( !file_attachments.isEmpty() )
    {
        //smtp->sendMail(settings.value("uname").toString(), settings.value("email to").toString(), ui->subject->text(),ui->msg->toPlainText(), file_attachments );
    }
    else
    {
        smtp->sendMail(settings.value("uname").toString(), settings.value("email to").toString(), ui->subject->text(),ui->msg->toPlainText());
        //smtp->sendMail(ui->uname->text(), ui->rcpt->text(), ui->subject->text(),ui->msg->toPlainText());
    }
    qDebug("finished sendmail");
}
예제 #4
0
void BalanceWindow::sendEmail(Settings::LevelBalance level){
    Smtp* smtp = new Smtp(settings->smtpLogin(),
                          settings->smtpPass(),
                          settings->smtpServer(),
                          settings->smtpPort());

    //connect(smtp, SIGNAL(status(QString)), this, SLOT(mailSent(QString)));

    QString levelText;
    QString subject;
    switch(level){
    case Settings::WARNING:
        levelText = "ниже рекомендуемого";
        subject = "Рекомендуется пополнить баланс";
        break;
    case Settings::CRITICAL:
        levelText = "ниже критического";
        subject = "Рекомендуется пополнить баланс";
        break;
    default:
        levelText = "нормальный";
        subject = "Сведения о балансе";
    }

    QString textMessage;

    QFile message(QString("%1\\mailText.html").arg(QApplication::applicationDirPath()));
    if(message.open(QFile::ReadOnly)){
        textMessage = QString(message.readAll());
        message.close();
    }

    smtp->sendMail("Balance Manager",
                   settings->smtpEmail(),
                   subject,
                   textMessage.arg(levelText)
                   .arg(settings->balance())
                   .arg(settings->needPay())
                   .arg(settings->updatePeriod())
                   );
}
예제 #5
0
void FLSmtpClient::startSend()
{
  emit sendStarted();

  emit sendTotalSteps(attachments_.count() + 3);

  int step = 0;

  emit sendStepNumber(++step);

  changeStatus(tr("Componiendo mensaje"), Composing);

  // only send logo when configured
  if (FLUtil::readSettingEntry("email/sendMailLogo", "true").toBool()) {
    QString logo(FLUtil::readSettingEntry("email/mailLogo",
                                          AQ_DATA + "/logo_mail.png").toString());
    if (!QFile::exists(logo)) {
      logo = AQ_DISKCACHE_DIRPATH + "/logo.png";
      QPixmap::fromMimeSource("logo_abanq.png").save(logo, "PNG");
    }

    attachments_ << logo;
    mapAttachCid_.insert(logo, QFileInfo(logo).fileName() + "@3d8b627b6292");
  }

  QString headerStr(QString::fromLatin1("from: ") + from_);
  if (!replyTo_.isEmpty())
    headerStr += QString::fromLatin1("\nreply-to: ") + replyTo_;
  headerStr += QString::fromLatin1("\nto: ") + to_ +
               QString::fromLatin1("\nsubject: ") + subject_;
  if (!cc_.isEmpty())
    headerStr += QString::fromLatin1("\ncc: ") + cc_;
  if (!bcc_.isEmpty())
    headerStr += QString::fromLatin1("\nbcc: ") + bcc_;
  if (!organization_.isEmpty())
    headerStr += QString::fromLatin1("\norganization: ") + organization_;
  if (priority_ > 0)
    headerStr += QString::fromLatin1("\npriority: ") +
                 QString::number(priority_);

  CharSets chS;
  HeaderClass hdr(headerStr.local8Bit());
  MessageClass msg(hdr);
  LocalMailFolder folder(AQ_DISKCACHE_DIRPATH + '/');
  QString idMessage = folder.createMessage(body_.local8Bit(), QCString(), QDateTime::currentDateTime(), "", &msg);
  IndexClass *idx = folder.indexIDict()[ idMessage ];
  MessageDevice msgDev(idx);

  MimePart *part0 = new MimePart();
  part0->charset = chS.getDefaultCharset();

  part0->mimetype = (mimeType_.isEmpty() ? "text/plain" : mimeType_);
  part0->encoding = "quoted-printable";
  part0->name = "body";
  part0->type = "text";
  QByteArray partData0 = body_.local8Bit();
  part0->length = partData0.count();
  int npart0 = idx->addPart(part0, false);
  msgDev.setPartData(npart0, partData0);

  emit sendStepNumber(++step);

  for (uint i = 0; i < textParts_.count(); i += 2) {
    part0 = new MimePart();
    part0->charset = chS.getDefaultCharset();
    part0->mimetype = textParts_[i + 1];
    part0->encoding = "quoted-printable";
    part0->type = "text";
    partData0 = textParts_[i].local8Bit();
    part0->length = partData0.count();
    npart0 = idx->addPart(part0, false);
    msgDev.setPartData(npart0, partData0);

    emit sendStepNumber(++step);
  }

  QStringList::Iterator itAttach;
  QString fileName;
  for (uint i = 0; i < attachments_.count(); i++) {
    itAttach = attachments_.at(i);
    fileName = *itAttach;

    changeStatus(tr("Adjuntando %1").arg(QFileInfo(fileName).fileName()), Attach);

    MimePart *part1 = new MimePart();
    part1->charset = chS.getDefaultCharset();
    QFile f(fileName);
    f.open(IO_Raw | IO_ReadOnly);
    QByteArray partData1 = f.readAll();
    f.close();
    part1->length = partData1.count();
    part1->name = QFileInfo(fileName).fileName();
    if (mapAttachCid_.contains(fileName))
      part1->cid = mapAttachCid_[fileName];
    const QMimeSource *mime = 0;
    QMimeSourceFactory *mimeFactory = mimeSourceFactory();
    if (mimeFactory) {
      mime = mimeFactory->data(fileName);
    } else {
      mime = QMimeSourceFactory::defaultFactory()->data(fileName);
    }
    if (mime && mime->format()) {
      part1->mimetype = mime->format();
      part1->encoding =  "base64";
    }
    int npart1 = idx->addPart(part1, false);
    msgDev.setPartData(npart1, partData1);

    emit sendStepNumber(++step);
  }

  QStringList rcpts(hdr.To.toQStringList());
  rcpts += hdr.Cc.toQStringList();
  rcpts += hdr.Bcc.toQStringList();

  Smtp *smtp = new Smtp(from_, rcpts, msgDev.rfc822Header(),
                        mailServer_, port_, this);

  smtp->setUser(user_);
  smtp->setPassword(password_);
  smtp->setConnectionType(connectionType_);
  smtp->setAuthMethod(authMethod_);

  emit sendStepNumber(++step);

  connect(smtp, SIGNAL(destroyed()),
          this, SIGNAL(sendEnded()));
  connect(smtp, SIGNAL(statusChanged(const QString &, int)),
          this, SLOT(changeStatus(const QString &, int)));
  smtp->init();
}
예제 #6
0
파일: SMTP.cpp 프로젝트: DeegC/10d
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
   // TODO: Place code here.
   CHAR *cNames[] = { "*****@*****.**", "*****@*****.**" };
   FILE *fp;

   CHAR szBody[45120] = "" ;
   CHAR szString[1024];


   Smtp sMailMessage;
   Smtp sMailMessage2;
   Smtp sMailMessage3;
   Smtp sMailMessage4;

   strcpy( szBody, "This is a plain Text EMAIL");
   sMailMessage.CreateSmtpConnection( "www.quinsoft.com" );
   sMailMessage.CreateSmtpMessage( "www.quinsoft.com",
                                  "*****@*****.**",
                           cNames,
                           1,
                           "Test",
                           1, // text
                           szBody,
                           0,
                           "" );

   strcpy( szBody, "");
   fp = fopen("C:\\Temp\\test2.html","r");
   while (fgets(szString,5120,fp))
   {
      strcat( szBody, szString );
   }
   fclose(fp);

   sMailMessage2.CreateSmtpConnection( "www.quinsoft.com" );
   sMailMessage2.CreateSmtpMessage( "www.quinsoft.com",
                                  "*****@*****.**",
                           cNames,
                           1,
                           "Test",
                           2, // HTML
                           szBody,
                           0,
                           "" );

   strcpy( szBody, "This is aNOTHER plain Text EMAIL with Attachment");
   sMailMessage3.CreateSmtpConnection( "www.quinsoft.com" );
   sMailMessage3.CreateSmtpMessage( "www.quinsoft.com",
                                  "*****@*****.**",
                           cNames,
                           1,
                           "Test",
                           1,
                           szBody,
                           1,
                           "C:\\temp\\text1.txt" );

   strcpy( szBody, "");
   fp = fopen("C:\\Temp\\test2.html","r");
   while (fgets(szString,1024,fp))
   {
      strcat( szBody, szString );
   }
   fclose(fp);
   sMailMessage4.CreateSmtpConnection( "www.quinsoft.com" );
   sMailMessage4.CreateSmtpMessage( "www.quinsoft.com",
                                  "*****@*****.**",
                           cNames,
                           1,
                           "Test",
                           2, // HTML
                           szBody,
                           1,
                           "C:\\temp\\test1.rtf" );
   return 0;
}