kaisellgren / mailer

Compose and send emails from Dart. Supports file attachments, HTML emails and multiple transport methods.
MIT License
168 stars 87 forks source link

Response from server: < 530 Authentication required #161

Closed berkayhh closed 3 years ago

berkayhh commented 3 years ago

Hi, i wanna use it for my Server ionos.de , i added actually all Parameters from the Server but the Password is not used in the Code , and the server Working with Authentication , how can i use the Password and send E-Mail ?

`import 'package:mailer/mailer.dart'; import 'package:mailer/smtp_server.dart';

mailyolla() async { String username = 'info@*.de'; String password = '***;

//final smtpServer = gmail(username, password); // Use the SmtpServer class to configure an SMTP server: final smtpServer = SmtpServer('smtp.ionos.de'); // See the named arguments of SmtpServer for further configuration // options.

// Create our message. final message = Message() ..from = Address(username, 'Your name') ..recipients.add('info@***.de') // ..ccRecipients.addAll(['destCc1@example.com', 'destCc2@example.com']) // ..bccRecipients.add(Address('bccAddress@example.com')) ..subject = 'Test Dart Mailer library :: πŸ˜€ :: ${DateTime.now()}' ..text = 'This is the plain text.\nThis is line 2 of the text part.' ..html = "

Test

\n

Hey! Here's some HTML content

";

try { final sendReport = await send(message, smtpServer); print('Message sent: ' + sendReport.toString()); } on MailerException catch (e) { print('Message not sent.'); for (var p in e.problems) { print('Problem: ${p.code}: ${p.msg}'); } } // DONE

// Let's send another message using a slightly different syntax: // // Addresses without a name part can be set directly. // For instance ..recipients.add('destination@example.com') // If you want to display a name part you have to create an // Address object: new Address('destination@example.com', 'Display name part') // Creating and adding an Address object without a name part // new Address('destination@example.com') is equivalent to // adding the mail address as String. final equivalentMessage = Message() ..from = Address(username, 'Your name') ..recipients.add(Address('info@**.de')) //..ccRecipients.addAll([Address('destCc1@example.com'), 'destCc2@example.com']) //..bccRecipients.add('bccAddress@example.com') ..subject = 'Test Dart Mailer library :: πŸ˜€ :: ${DateTime.now()}' ..text = 'This is the plain text.\nThis is line 2 of the text part.' ..html = "

Test

\n

Hey! Here's some HTML content

";

final sendReport2 = await send(equivalentMessage, smtpServer);

// Sending multiple messages with the same connection // // Create a smtp client that will persist the connection var connection = PersistentConnection(smtpServer);

// Send the first message await connection.send(message);

// send the equivalent message await connection.send(equivalentMessage);

// close the connection await connection.close(); print("Message Sent.");

}`

Thx-Best Regards

berkayhh commented 3 years ago

I got it right now,

final smtpServer = SmtpServer('mailserver url here', username: username, password: password);

Thx for the Information at https://github.com/kaisellgren/mailer/issues/158#issuecomment-760525930