09/10/2018, 22:50

Viết code php để gửi mail ???

Code thì mình biết rồi , dùng mail () function hoặc Pear .

Nhưng còn cấu hình "incoming mail server" và "outgoing mail server" trong file php.ini thì mình chịu . Bạn nào biết chỉ giúp với !

Trong file php.ini mình configure như thế này :

[mail function]
; For Win32 only.
SMTP = gmail.com
smtp_port = 25

; For Win32 only.
sendmail_from = dungdeveloper@gmail.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_paramaters =

Nhưng mãi chưa gửi mail được ! Help me .
duyphian viết 00:50 ngày 10/10/2018
Quote Được gửi bởi dungdeveloper
Code thì mình biết rồi , dùng mail () function hoặc Pear .

Nhưng còn cấu hình "incoming mail server" và "outgoing mail server" trong file php.ini thì mình chịu . Bạn nào biết chỉ giúp với !

Trong file php.ini mình configure như thế này :

[mail function]
; For Win32 only.
SMTP = gmail.com
smtp_port = 25

; For Win32 only.
sendmail_from = dungdeveloper@gmail.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_paramaters =

Nhưng mãi chưa gửi mail được ! Help me .
Vẫn chưa gửi được vì sai SMTP
Bác dùng SMTP của Google làm sao được

http://www.vuiqua.com
dungdeveloper viết 00:58 ngày 10/10/2018
Ủa sao kỳ vậy, bác lkn thì nói không dùng smtp, còn bác duyphian thì bảo dùng smtp của google cũng không được ???

Nói tóm lại, làm sao thì các bác chỉ cụ thể cho 1 chút với, đừng nói bâng quơ vậy chớ ! :-)
ncanh viết 00:54 ngày 10/10/2018
Quote Được gửi bởi dungdeveloper
Ủa sao kỳ vậy, bác lkn thì nói không dùng smtp, còn bác duyphian thì bảo dùng smtp của google cũng không được ???
Nói tóm lại, làm sao thì các bác chỉ cụ thể cho 1 chút với, đừng nói bâng quơ vậy chớ ! :-)
Cái này hơi phức tạp đấy bạn.
1. Trong *nix có sẵn mailserver rồi nên bạn dùng hàm mail của php thoải mái.
Trong win thì bạn phải download 1 mailserver xuống, install và run.
Phải nghịch ngợm 1 thời gian với mailserver này cho quen: tạo mail account, tạo admin-acount.
2. Phải có domain và biết cách nối domain này vào Web-IP của bạn. Lúc ấy cái server của bạn mới "có tiếng" trong mạng để có thể gởi mail đến và đi được. Việc làm này cũng đòi hỏi một thời gian nữa.


Sau đâu đó bạn chỉnh trong php.ini:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = admin@domainX.y

Với "admin@domainX.y" là addmin acount trong mail-server .

Sao? Thấy dễ không?
Mấy bạn trước nói bâng quơ vì nếu trả lời cụ thể thì sẽ phải mất vài ngày chứ không chơi.


NC
dungdeveloper viết 01:00 ngày 10/10/2018
Ồ cám ơn bạn ncanh nhiều nhé, bạn nói có vẻ dễ hiểu lắm đấy !
canthobuon viết 00:55 ngày 10/10/2018
Bạn nên tìm trong forum đi trước kia mình có hướng dẫn người khác dùng phpxmail để làm chức năng SMTP cho bạn gửi thư đi và uebimiau (tiếng brazil hay bồi đào nha) là server để cho bạn nhận email.

Nếu bạn dùng windows thì mình đề nghị bạn nên download Apache2Triad phiên bản 1.5 sau khi setup xong nó có sẵn phpxmail và uebimiau, bạn chỉ cần setup DNS server và config phpxmail và uebimiau là có thể nhận và gửi email ngon lành. Nếu dùng windows XP thì setup hosts file thay cho DNS. Mình thấy setup uebimiau với đúng domain name hơi phức tạp, nhưng cũng không khó lắm đâu nếu bạn có DNS hoạt động rồi.

Nhớ khi nào setup xong phpxmail và uebimiau đừng có gửi bom thư tới tôi nhé.
duongdragonxxx viết 01:04 ngày 10/10/2018
Vậy còn gởi mail bằng STMP thì làm như thế nào (asp.net) có bác nào giúp em với không. Cái code thì chuyện nhỏ, nhưng còn cái phần cấu hình thì em pó tay, đã thử cấu hình nhìu lần rùi nhưng không xi nhê gì hết. Chương trình thì báo mail đã được gởi, nhưng mail lại không nhận được. Dương đang sử dụng mail server STMP localhost.
---------------------
email: duongdragon***@yahoo.com
---------------------
box của hội .net
http://www.itgatevn.com.vn/forum.aspx?u=ShowForum&id=11
malefly viết 01:02 ngày 10/10/2018
To DuongDragon SMTP not STMP

But first you'll need to check if the Microsoft SMTP Service is turned on. To do this either open the Internet Services Manager directly or open Computer Management and Navigate to Internet Information Services -> Default SMTP Virtual Server and checkout if the button with the 'play' icon on it is disabled, that means it is already started.

Microsoft SMTP Service is the one we'll use in this article, but you can as well use something more professional like the Microsoft Exchange Server. The reason why we're using the first mentioned is because it's included in Windows XP Professional and Windows 2000.
Testing Microsoft SMTP Service
It's better to test it before using it in an ASP .NET application so if it doesn't work, at least you can't blame it on the web application. It's incredible how easy it is to test this service.
By default, your folder for IIS files is located somewhere in C:\Inetpub. In addition, the folders that Microsoft SMTP Service uses are located here, more exactly the folder is called mailroot. The SMTP service uses these folders to store email messages. You can see a total of seven folders, the most important one for sending email is Pickup - open this folder. Now start the best editor possible: Notepad. In it paste the following lines:

To: phamleminhtris@yahoo.com
From: Duongdragon@yahoo.com

Subject: Hello MaleFly

I'm testing the Microsoft SMTP Service, didn't meant to bother.

You recognize the typical fields used to send email, to, from and subject and below the content of the email. In the From field you can enter any email address you want, even if it's not yours. Now save this file in the Pickup folder using any name you wish, test.txt for example. The next second it should disappear... that's because it was sent. If you leave the fields unchanged, it will send it to my email address and I'll know that you're reading my article right now.

Now that we settled this out, we can start developing. Fire up Microsoft Visual Studio .NET and start a new ASP .NET Web Application.
To the WebForm add four TextBoxes, the last one should have the property TextMode set to MultiLine (makes it a textarea). Also, add a button to the recipe. The entire layout should look like this:



I recommend setting the ID property of each textbox to txtFrom, txtTo, txtSubject and txtContent and for the button btnSend so that we don't confuse them.

Now we get to my favorite part, coding. Open WebForm1.aspx.cs, the first thing we must do is import the namespace where SmtpMail and MailMessage classes are:

using System.Web.Mail;

Next, create a new instance of the MailMessage class:

protected MailMessage MMsg;

Double click the button on the WebForm to get to the btnSend_Click() event. Inside paste the following code:

MMsg = new MailMessage();
MMsg.From = txtFrom.Text;
MMsg.To = txtTo.Text;
MMsg.Subject = txtSubject.Text;
MMsg.Body = txtContent.Text;
SmtpMail.Send(MMsg);

We create a new instance of MailMessage on the first line and then we set several properties needed to send the message. The last line actually sends the email by using the Send() method of SmtpMail.
Sometimes when you upload your website to a webhost you'll have to change the SMTP server. This can be done by changing the SmtpServer property:

SmtpMail.SmtpServer = "localhost";

localhost is the name of the SMTP server but you could as well enter an IP.

As you can see, sending emails is a very simple task in ASP .NET and can be done just by setting a few properties. The application is now fully functional and you can compile it, run it, fill in the fields and press btnSend.

There are some other properties you can set, like CC (Carbon Copy) or BCC (Blind Carbon Copy) which are both well known in email messaging.
Another property you might be interested in is Priority, which can set the message priority to Low, Normal or High.
Here's an example of how to use it:

MMsg.Priority = MailPriority.High;

We all know that email messages can be either plain text or HTML. By default they are sent as plain text, but you can change this by setting the BodyFormat property to Html:

MMsg.BodyFormat = MailFormat.Html;


In sort :

If you fell this article are useful for you

you should reply "Thank thank thank " malefly 1000 times

Otherwise "Malefly " too bad
ncanh viết 00:54 ngày 10/10/2018
Quote Được gửi bởi canthobuon
...uebimiau (tiếng brazil hay bồi đào nha) là server để cho bạn nhận email....
...Nếu bạn dùng windows thì mình đề nghị bạn nên download Apache2Triad phiên bản 1.5 sau khi setup xong nó có sẵn phpxmail và uebimiau, bạn chỉ cần setup DNS server và config phpxmail và uebimiau là có thể nhận và gửi email ngon lành....
uebimiau là "mail client" chứ không phải "mail server". Mail server trong Apache2Triad này là "Xmail".
phpxmail là ứng dụng đồ họa (gui) để kiểm soát mail server xmail.

Nói chung Apache2Triad là cách đi đường tắt rất nhanh để đến đích. Vì nó tổng hợp tất cả các thứ cần thiết để biến 1 computer thành một multi-servers: Webserver, Databaseserver, Mailserver, FTPserver, SSLserver cùng với các công cụ lập trình: Perl, Php, Python, TCL,...

Một lập trình viên về mạng cần có tất cả những thứ đó.



NC
duongdragonxxx viết 01:04 ngày 10/10/2018
So, I do it like u say but I recive a message:
"
This is an automatically generated Delivery Status Notification.
Delivery to the following recipients failed.
"
u can help me solve problem.
Thank u very much!
Bài liên quan
0